How can I cover up areas of a plot?

조회 수: 8 (최근 30일)
John
John 2014년 3월 28일
댓글: Image Analyst 2014년 3월 28일
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.

답변 (1개)

Image Analyst
Image Analyst 2014년 3월 28일
Try patch() or fill().
  댓글 수: 2
John
John 2014년 3월 28일
Hi,
I had a look in the help but I'm really not sure how I'd go about converting the mask I have into something useful for either of those functions. Could be you a bit more specific?
Image Analyst
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 CenterFile Exchange에서 Contour Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by