How to change the x axis label
7 views (last 30 days)
I am plotting a matrix output using imagesc and my x-axis is labeled from 1-151 however I would like the x-axis labels to be between 4.5:.01:6 but still display the full contents of the image. How would I do the relabeling? Thank you in advance.
Image Analyst on 31 May 2013
Setting tick labels won't do it because the first tick mark is not at the left edge of the image. You need to pass in x and y values into imagesc() and it will all work out fine:
% Read in sample image.
grayImage = imread('cameraman.tif');
% Determine how many rows and columns.
[rows columns] = size(grayImage);
% Determine scaling for the axes.
x = linspace(4, 6, columns);
y = 1:rows;
% Display image along with our custom axes tick marks.
imagesc(x, y, grayImage)