Tickmarks not showing up on imagesc figure?
Show older comments
I used imagesc on an array to visualize it... my issue now is with setting the tick marks on the axes. I want there to be only two tick marks on the x and y axis each with -1 and 1 so I do xticks([-1 1]) and yticks([-1 1]) but on the figure the only thing that shows up are the y ticks and those ticks are 1 at the bottom and 1 at the top, which should be -1 at the bottom and 1 at the top, and then the same for the x axis... any help?
Answers (1)
Image Analyst
on 14 Mar 2018
Use the 'XData' and 'YData' options:
rgbImage = imread('peppers.png');
imagesc(rgbImage, 'XData', [-1,1], 'YData', [-1,1]);
axis on
xticks([-1, 1]);
yticks([-1, 1]);
2 Comments
Hunter Weaver
on 14 Mar 2018
Image Analyst
on 14 Mar 2018
Here's proof it works:
rgbImage = imread('peppers.png');
rgbImage = imresize(rgbImage, [100,100]); % Make it 100x100
imagesc(rgbImage, 'XData', [-1,1], 'YData', [-1,1]);
axis on
xticks([-1, 1]);
yticks([-1, 1]);

Please post your code with proof that it doesn't work.
Categories
Find more on Axis Labels in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!