How can I make the x and y labels start at the origin?
12 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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.
0 Commenti
Risposta accettata
Cris LaPierre
il 28 Gen 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});
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Axis Labels in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!