Effacer les filtres
Effacer les filtres

contourf nolinear y axis

2 vues (au cours des 30 derniers jours)
KatPa
KatPa le 23 Sep 2019
Dear all!
For a couple of days I am struggling with the following problem and I hope someone here could help me with that. I am using the contourf function to plot my 3D array, I first specifiy x (time), then y (frequencies), then Z power values (array size time x frequencies). The plot looks fine fist, but then I noticed that my axes are plotted lineary. While this is fine for the x axis (time), this does not work for the y axis, where the distances between each frequency is not linear.
On the reference page I read that "If X or Y is irregularly spaced, then contourf calculates contours using a regularly spaced contour grid, and then transforms the data to X or Y."
So now I wonder how I could change this, to to set the Y axis in a non-linear fashion, representing my input.
Thank you,
Kat

Réponses (1)

Naveen Venkata Krishnan
Naveen Venkata Krishnan le 10 Oct 2019
Hello Kat,
As far as I understood from the description, you have irregulary spaced Y ( assuming only Y is irregulary spaced and X is regularly spaced ) and then you have contourf plot on which you want see your irregularly spaced Y instead of default regularly spaced values.
This can be done in this way :
X = 1:5;
Y = [2,6,9,11,18];
Z = peaks(5);
ax =axes; % handle to the current axes
contourf(X,Y,Z);
ax.YTick = Y; %since Y is irregularly spaced and only that points must be seen on the axes

Catégories

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

Community Treasure Hunt

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

Start Hunting!

Translated by