Hello,
In my contourf plot, I want to cut off values above a certain limit, 61 in this case. In the attached figure, I want to have the figure on the right to look like the figure on the left upto the 61 line. However if I set these values to either zero or nan, the edge will always be tapered. Is there a way display the edge like a smooth contour line, like all others in the figure?
Thanks in advance!
The figure on the left is created by
figure()
contourf(W_chh*10^6,W_ww*10^6,(Twout'))
colorbar
The figure on the right is created by
figure()
Twout(Twout >= 61) = nan;
contourf(W_chh*10^6,W_ww*10^6,(Twout'))
colorbar

댓글 수: 7

ADSW121365
ADSW121365 2020년 6월 15일
You might be able to force the behaviour by plotting the full graph, then setting an xlim to crop out the extra part of the graph without deforming your curves.
Lars Peters
Lars Peters 2020년 6월 15일
편집: Lars Peters 2020년 6월 15일
Thank you for your answer, however if I limit the colorbar in the original figure, all values above 61 will get the color coresponding to the maximum value set as limit, and will still be in the graph. In this case, these values are physically not possible and therefore need to be removed completely.
Adam Danz
Adam Danz 2020년 6월 15일
편집: Adam Danz 2020년 6월 15일
If you want the colors to have the same definition for both plots, you can set the color limits of the second axes to have a range from ~56 to 64 or whatever the range is in the first plot. Currently, "yellow-ish" means ~63 on the plot on the left but the same exact color means ~60 on the plot on the right.
Lars Peters
Lars Peters 2020년 6월 15일
It is not about the colors, I will not use the first figure but I just added it as an example. It's about how to get cut off the graph in such a way that there will be a smooth line at the edge, just like this line is present in the first figure at 61 instead of the block line thing that is currently present in the right figure at 61.
Adam Danz
Adam Danz 2020년 6월 15일
It sounds like the step-like contour edge at level 61 is part of your data and you want to modify that controur line as if your data doesn't have that feature in it. I'll update my answer with an alternative.
Lars Peters
Lars Peters 2020년 6월 15일
The same questions holds for this figure, I don't know the values in this case, just the matrix index of the part that needs to be cut off, which I did. Maybe this clears the confusion.
Adam Danz
Adam Danz 2020년 6월 15일
My updated answer suggests to plot the contour lines without modifying the inputs. Then, after the contrours are plotted, remove the levels greater than your threshold.

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

 채택된 답변

Adam Danz
Adam Danz 2020년 6월 15일
편집: Adam Danz 2020년 6월 15일

2 개 추천

See the 'levels' option. You could get the levels from the first controur plot and use the same levels for the 2nd plot.
Also see caxis() to control the color limits so that they match between the two axes.
[update]
Alternatively, you could produce the controur plot without the levels input and then, after plotting, remove levels greater than 61.
[~, c] = contourf(W_chh*10^6,W_ww*10^6,(Twout'));
c.LevelList(c.LevelList > 61) = [];
Then add white to the very end of your color map and set the color range so the max values are white.
ax = gca();
ax.Colormap(end,:) = 1; % Max color is now white
A potentially ugly approach would be to get the coordinates of the jagged controur line, smooth them, then replot the smoothed line.

댓글 수: 4

Hello, I have tried that by adding the following, but the edge is still tapered. If I remove the second line, the edge is smooth but then all values larger than 61 will map this value, where I would like them removed.
figure()
Twout(Twout >= 61+273) = nan;
contourf(W_chh*10^6,W_ww*10^6,(Twout'-273),[56:61])
colorbar
caxis([56 61])
Adam Danz
Adam Danz 2020년 6월 15일
You could alter your colormap so that values >61 are mapped to white.
Lars Peters
Lars Peters 2020년 6월 15일
편집: Lars Peters 2020년 6월 15일
Thank You!
Adam Danz
Adam Danz 2020년 6월 15일
Glad I could help.

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

추가 답변 (0개)

카테고리

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

태그

질문:

2020년 6월 15일

댓글:

2020년 6월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by