Cutting line/contour line in graph

조회 수: 5 (최근 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 CenterFile Exchange에서 Map Display에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by