필터 지우기
필터 지우기

contourf nolinear y axis

조회 수: 2 (최근 30일)
KatPa
KatPa 2019년 9월 23일
답변: Naveen Venkata Krishnan 2019년 10월 10일
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

답변 (1개)

Naveen Venkata Krishnan
Naveen Venkata Krishnan 2019년 10월 10일
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

카테고리

Help CenterFile Exchange에서 Contour Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by