How to change the x axis label

6 views (last 30 days)
Ryan on 31 May 2013
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.

Accepted Answer

Image Analyst
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)
axis on;

More Answers (1)

Azzi Abdelmalek
Azzi Abdelmalek on 31 May 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!