Smooth edge on contour plot

4 ビュー (過去 30 日間)
Lars Peters
Lars Peters 2020 年 6 月 15 日
コメント済み: Adam Danz 2020 年 6 月 15 日
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 件のコメント
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 日
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 件のコメント
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 件)

カテゴリ

Help Center および File ExchangeContour Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by