How to add axis in a figure where I'm drawing lines.
2 views (last 30 days)
This is the code I'm using.
I = imread('figure251.png');
figure, imshow(I); colormap hot ;
p1 = [125.5,125.5];
p2 = [125.5,130.5];
p3 = [130.5,125.5];
p4 = [130.5,130.5];
p5 = [125.5,125.5];
p6 = [130.5,125.5];
p7 = [125.5,130.5];
p8 = [130.5,130.5];
I need to put axis in the above program. But if I zoom in then the no of points in the axis reduces. if I use axis on only then it coms as piel no. Then I can zoom in. I want to zoom in with more axis label.
DGM on 11 Jun 2022
Edited: DGM on 11 Jun 2022
You can set xdata,ydata for imshow() as you do with image()/imagesc(), but by default imshow() will turn off axis visibility. You can turn it back on, but then you have to deal with the fact that the figure has been set up without consideration for the area required to show ticks and axis labels. You may have to adjust the position of the axes object to make room for everything.
I = imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1028490/image.png');
xylim = [-90,90].*4.65./1000;
The utility of imshow() is its conveniences for viewing pictures without extraneous axis decorations. If you're using it with the axis visible, I'm not sure why you wouldn't just use image()/imagesc() instead. You might need to set axis equal if you do, but that's about it.
FWIW, the first answer is a bit misleading. Both image() and imshow() will display RGB images in truecolor and they'll both display grayscale images using a colormap. The only difference is that imshow() forces the use of a gray colormap instead of whatever map was being used in the axes at the time. Again, that's considered a matter of convenience. If you explicitly set the map after the the image is displayed, there really isn't any difference.