How can I cover up areas of a plot?

8 次查看(过去 30 天)
John
John 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