Cutting line/contour line in graph
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Adam Danz
le 17 Mai 2021
Modifié(e) : Adam Danz
le 17 Mai 2021
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 commentaires
Voir également
Catégories
En savoir plus sur Map Display dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!