How to change image axis labels

旧城冷巷雨未停 提交于 2019-11-28 09:26:36

From your question I infer that you want to set the x-axis labels from -180 to 180, and the y-axis labels from -90 to 90. To do this, you should change the XTickLabel and YTickLabel properties of the axis object (note that you'll also need to adjust the number of ticks in each axis by modifying the XTick and YTick properties accordingly).

So, assuming that your image is stored in the matrix data and you display it with imagesc(data), here's how to change the tick labels in the x-axis to be from -180 to 180:

xticklabels = -180:20:180;
xticks = linspace(1, size(data, 2), numel(xticklabels));
set(gca, 'XTick', xticks, 'XTickLabel', xticklabels)

Similarly, here's how to change the tick labels in the y-axis to be from -90 to 90:

yticklabels = -90:20:90;
yticks = linspace(1, size(data, 1), numel(yticklabels));
set(gca, 'YTick', yticks, 'YTickLabel', flipud(yticklabels(:)))

This is what it should look like:

Can't say I fully understand what you mean, so here goes. To add a label to an axis use xlabel and ylabel, for example:

xlabel('time [sec]'); ylabel('Amplitude');

To change the labels of the axis ticks, use something like:

plot(1:4)
set(gca,'Xtick',1:4,'XTickLabel',{'a', 'b', 'c', 'd'})

Working with imagesc you may want to add this line:

set(gca, 'YDir', 'reverse');

this will set the numbers on the Ticks growing for the bottom left corner...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!