Cutting line/contour line in graph
6 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(1 个)
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Map Display 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!