Borrar filtros
Borrar filtros

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

16 visualizaciones (últimos 30 días)
Al Gut
Al Gut el 28 de En. de 2021
Editada: Al Gut el 29 de En. de 2021
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.

Respuesta aceptada

Cris LaPierre
Cris LaPierre el 28 de En. de 2021
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});

Más respuestas (0)

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by