I have been trying to display solid black gridlines using the imagesc function, such that each pixel has a black boundary around it. I have tried a few methods, but it seems that no matter what, the lines always go through the pixel. As an example, for imagesc(randn(21,21)), I am trying to get a plot where each square (ie. pixel) here has a black border.
I found one solution here: In matlab, how to draw a grid over an image, but I am unsure how to get it to work with imagesc, and not a.jpg image.
I have also tried using the hold on function to place the lines manually. But every solution, it seems that the grid lines pass through the middle of the pixel. Any help would be appreciated. Thank you.