How to change the x axis label

Hello!
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.

 Respuesta aceptada

Image Analyst
Image Analyst el 31 de Mayo de 2013

0 votos

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;

Más respuestas (1)

Azzi Abdelmalek
Azzi Abdelmalek el 31 de Mayo de 2013

0 votos

xt=get(gca,'xtick')
new_xt=num2cell(linspace(4,6,numel(xt)))
set(gca,'xticklabel',new_xt)

Categorías

Etiquetas

Preguntada:

el 31 de Mayo de 2013

Community Treasure Hunt

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

Start Hunting!

Translated by