Axes ticks labeling in contourf

15 vues (au cours des 30 derniers jours)
Shani Gal
Shani Gal le 19 Fév 2012
Modifié(e) : Matt J le 16 Oct 2013
Hi
How do I label the X and Y ticks in contourf ? if I have a 20x30 matrix, when I use contourf the x-axis is labeled from 0 to 20 and the y from 0 to 30, how do I change it to different values ( for example the x should be from 100 to 120 and the y from 200 to 230)
Thanks
Shani

Réponse acceptée

Walter Roberson
Walter Roberson le 19 Fév 2012
Provide the x and y values at the time of the contourf() call.
contourf(X,Y,Z), contourf(X,Y,Z,n), and contourf(X,Y,Z,v) draw filled contour plots of Z using X and Y to determine the x- and y-axis limits. When X and Y are matrices, they must be the same size as Z and must be monotonically increasing.

Plus de réponses (1)

the cyclist
the cyclist le 19 Fév 2012
For example:
set(gca,'XTick',100:2:120,'XTickLabel',100:2:120)
EDIT IN RESPONSE TO COMMENT:
Here is a fuller example:
z = peaks;
figure
contourf(z);
set(gca,'XTick',10:10:40,'XTickLabel',10:10:40)
"gca" means "get current axis".
  2 commentaires
Shani Gal
Shani Gal le 19 Fév 2012
tried it, it doesn't work
what gca refer to?
Shani Gal
Shani Gal le 19 Fév 2012
Hi
still doesn't work, the x-axis should vary from 0 to 261, I have 20 cells, now they are labeled 2, 4, ...20 and I wish them to be labeled 26.1 (2*261/20) 52.2 ( 4*261/20) and so on...
How do I do that?
Thanks,

Connectez-vous pour commenter.

Catégories

En savoir plus sur Contour Plots dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by