Skip to content
Advertisement

Adjusting gridlines and ticks in matplotlib imshow

I’m trying to plot a matrix of values and would like to add gridlines to make the boundary between values clearer. Unfortunately, imshow decided to locate the tick marks in the middle of each voxel. Is it possible to

a) remove the ticks but leave the label in the same location and
b) add gridlines between the pixel boundaries?

JavaScript

Image without the gridline and with tick marks in the wrong location enter image description here

JavaScript

Image with gridlines in the wrong location:

enter image description here

Advertisement

Answer

Try to shift axes ticks:

JavaScript

enter image description here

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement