Why is auto-scaling not following data on contour-plot?

I am creating two colour plots from matrix values, one with the heatmap(...) function and one with the contourf(...) function. The results are these:
And the code used to generate them is this:
xvalues = {'20 C','30 C','40 C','50 C','60 C','70 C','80 C','90 C'};
yvalues = {'80 %','60 %','40 %'};
figure(1)
c=heatmap(xvalues,yvalues,heat)
c.Colormap=parula;
figure(2)
contourf(heat)
set(gca, 'YDir', 'reverse')
set(gca,'xticklabel',xvalues)
set(gca,'yticklabel',yvalues)
colorbar
The matrix heat consists of 3 rows and 8 columns:
No tick-placing is done in the code. Only tick-labelling (and the issue happens with and without the labelling).
As you can see on the plots, the heatmap correctly auto-generates 8 ticks on the x-axis (due to the 8 columns) and 3 ticks on the y-axis (due to the three rows).
But not on the contour plot - there only the x-axis is correctly ticked with 8 ticks. And therefore my labelling fits the tick number. On the y-axis many ticks are auto-generated so my three labels are simply duplicated.
Why does the auto-generation of y-ticks not fit the 3 rows?

댓글 수: 3

Adam
Adam 2018년 4월 5일
편집: Adam 2018년 4월 5일
You can set the 'YTick' property manually and you should do this when you change labels. Otherwise your labels will just get cycled round as you see) to fill all the ticks. If you set the 'YTick' to the 3 values you want then your 3 tick labels will also match.
The auto tick generation algorithm doesn't just generate ticks at integers, it will generate at multiple of 0.5 or whatever it thinks appropriate (I have no idea what the algorithm is, but I guess by default it seeks to have more than just 3 ticks even if you only have 3 rows of data)
@Adam Ok, it feels odd that the auto-generated ticks are different on the two plots, though.
Yes, heatmap does its own things and is a different kind of plot to image plots or contour plots.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

태그

질문:

2018년 4월 5일

댓글:

2018년 4월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by