Cutting line/contour line in graph

3 ビュー (過去 30 日間)
Luh Putri Adnyani
Luh Putri Adnyani 2021 年 5 月 17 日
コメント済み: Adam Danz 2021 年 5 月 20 日
Hi all,
Does anyone here know how to cut the line/contour line on the graph as shown in one of the papers below?
while the original result is like the image below.
I tried to use a box plot like the code below, but the contour line still continue to depth -10m, not stop in the plot box. does anyone can provide ideas how to solve it?
x=ncread('roms_his.nc','x_rho')/1000;
z=ncread('roms_his.nc','s_rho').*(10);
salt=ncread('roms_his.nc','salt');
[xo,zo]=meshgrid(x(:,1),z);
contour(xo',zo',squeeze(salt(:,1,:,1)),'ShowText','on');
xticks(0:10:100);
x1=0;
x2=100;
y1=-0;
y1=-10;
y2=-0.5;
y2=-5;
y3=0;
x_box = [x1, x1, x2, x2, x1];
y_box = [y1, y3, y3, y2, y1];
plot(x_box, y_box, 'b-', 'LineWidth', 3);
hold on
contour(xo',zo',squeeze(salt(:,1,:,1)),'ShowText','on');
hold off
xticks(0:10:100);
xlabel('Distance, km')
ylabel('Depth, m')
title(['Initial salinity distribution for estuary simulations'])
Thanks before.

回答 (1 件)

Adam Danz
Adam Danz 2021 年 5 月 17 日
編集済み: Adam Danz 2021 年 5 月 17 日
Since you know the coordinate of the blue trapazoid, you can create a white patch object that is equal to the area under the trapazoid and plot the white patch on top of the contour object but under the blue trapazoid object. That will hide any contour lines below the blue line.
Use patch or fill.
Alternatively, with a lot more work you could get the coordinate values of the contour lines using any number of file exchange submissions and then eliminate any coordinates below the blue line but then the contour lines may not touch the blue line.
  2 件のコメント
Luh Putri Adnyani
Luh Putri Adnyani 2021 年 5 月 18 日
Yes. Thank you. It works
Adam Danz
Adam Danz 2021 年 5 月 20 日
Glad I could help.
Consider accepting the answer (blue accept button).

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLighting, Transparency, and Shading についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by