- use patch() or surface() or one of the derived functions fill() or contourf() to create a closed bounded object which has a face which is coloured with the desired fill colour.
- convert some or all of the axes content into an image in which you have painted the desired fill colour and carefully place the image on the axes.
Fill the plot but it should not be closed by connecting first vertex to the last
6 views (last 30 days)
Show older comments
I have a plot which consists of alternate layers of two species. I need to fill these layers with specified colors but it should not be closed by connecting last vertex to the first. When I use the fill command it connects the vertices and I do not want it that way. Please guide.
0 Comments
Answers (1)
Walter Roberson
on 10 Oct 2015
There are two ways to handle fill in MATLAB:
I would wonder if the issue is not that you do not want the polygon to be closed, but rather that you do not want the edge to be drawn? An example of what you want would help.
2 Comments
Walter Roberson
on 10 Oct 2015
You would normally proceed by constructing closed boundaries with the first connected to the last. It just might not be the boundaries you thought of at first.
Presuming that the X values are all the same, and letting the red and black lines be columns in Y, then, to fill between columns K and K+1 you would construct
fx = [X(:); flipud(X(:))];
fy = [Y(:,K); flipud(Y(end,K+1))];
col = [0 0 0] or [1 0 0] or as appropriate
fill(fx, fy, col, 'edgecolor', 'none');
See Also
Categories
Find more on Graphics Object Properties in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!