How can I cover up areas of a plot?
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Image Analyst
am 28 Mär. 2014
Try patch() or fill().
2 Kommentare
Image Analyst
am 28 Mär. 2014
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/
Siehe auch
Kategorien
Mehr zu Contour Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!