How can I make the x and y labels start at the origin?

14 次查看(过去 30 天)
This is my code to plot a matrix with imagesc:
imagesc(f);
set ( gca, 'ydir', 'normal' )
colorbar
ticks=[0:12.5:100];
xticks(ticks);
xticklabels({100:100:800});
yticks(ticks);
yticklabels({10:10:80});
--- I want the axis to start in the origin with x=100 and y=10 but it start to write labels one xtick later. How can I fix that? I want to have my first tick label in the origin and with a value of x=100, y=10.

采纳的回答

Cris LaPierre
Cris LaPierre 2021-1-28
The issue is that you are specifying your first tick to be at 0. Image X and Y values come from the column and row indices of the array, respectively. MATLAB does not use an index of 0. It starts at 1. Therefore, your first tick is getting skipped. Start your ticks at one instead.
Also note that you have specified 9 tick locations but only 8 labels.
Z = 10 + peaks(100);
imagesc(Z)
set ( gca, 'ydir', 'normal' )
colorbar
ticks=linspace(1,100,8);
xticks(ticks);
xticklabels({100:100:800});
yticks(ticks);
yticklabels({10:10:80});

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Axis Labels 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by