How to create contour plot within a 2D plot

Hi all,
I have to create such a plot but I have no idea how to do it. Can anyone guide me?
I know the equation for mean overtopping discharge and my question is how to draw the colored area (contour).
Cheers,
Soheil

답변 (1개)

Abdolkarim Mohammadi
Abdolkarim Mohammadi 2020년 8월 15일

0 개 추천

When you want to draw multiple plots within one axes, you should put all of the commands between hold on and hold off.
hold on
plot(...);
scatter(...);
contour(...);
hold off

댓글 수: 4

Thank you for your help
But my question is how to have a contour only in the area between the lines (as shown in the figure)
Abdolkarim Mohammadi
Abdolkarim Mohammadi 2020년 8월 15일
편집: Abdolkarim Mohammadi 2020년 8월 15일
Regular plot functions (like surf and contour) usually require rectangular matrices. However, non-rectangular patches like the one you posted are made via triangulation. You need to have x, y, and z coordinates of the colored patch in the form of column vectors. Then use delaunay function to triangulate the data. Next you plot the triangles using trisurf. By setting the EdgeColor of the trisurf to remove the mesh, you get the patch like the one you posted. You also need to set the view property of the axes to view the plot in 2D.
I really thank you for your help.
I was able to get the same output as the attached figure.
But one problem I have is that the drawn contour is on the blue lines
While I want the contour to be below the blue lines
When I change the order of the commands, nothing changes.
What do you think is the solution?
use plot3 for the lines and give a z coordinate that is greater than 0. When you use contourf() the patches it draws are all at z=0

댓글을 달려면 로그인하십시오.

카테고리

태그

질문:

2020년 8월 15일

댓글:

2020년 8월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by