How can I cover up areas of a plot?
조회 수: 8 (최근 30일)
이전 댓글 표시
Basically I'm plotting contours on a grid, but I want to cover part of the plot area up.
The contours are defined on a grid with x and y vectors:
contour(x,y,C)
I want to be able to cover sections of the plot with a filled area determined by whether a grid point is included in the area or not. So for example, for the given points on an 8x6 grid:
mask = [1 1 1 1 0 0 0 0
1 1 1 1 0 0 1 1
0 0 0 0 0 0 1 1
0 0 0 0 1 0 0 0
0 0 0 1 1 0 0 0
0 0 0 0 0 0 0 0];
I want to superimpose my contour plot with a rectangle, a square, and a triangle, at the corresponding positions in the grid. Does anybody have any idea how to go about doing this? I'm at a complete loss. I still need the underlying contour plot to be visible at those points marked '0', I just want to fill in the squares/triangles on the grid bounded by '1's.
I can plot the points that bound the areas just with
plot(x,meshgrid(x,y).*mask)
but I want to fill in the areas in between, not just have points.
댓글 수: 0
답변 (1개)
Image Analyst
2014년 3월 28일
Try patch() or fill().
댓글 수: 2
Image Analyst
2014년 3월 28일
Well you have to get the vertex coordinates. Alternatively you could follow Steve's suggestion: http://blogs.mathworks.com/steve/2009/02/18/image-overlay-using-transparency/
참고 항목
카테고리
Help Center 및 File Exchange에서 Contour Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!