![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/361303/image.png)
Filling between several curves in a figure using fill or patch functions
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
hamed
el 16 de Sept. de 2020
Comentada: Ameer Hamza
el 22 de Sept. de 2020
Hi
I have a figure, in which 4 curves are plotted. I want to fill between these curves twp by two with a specific color (red, green, ...) I attached the plots I want to fill. How can I do that?
Thanks
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/361237/image.png)
0 comentarios
Respuesta aceptada
Ameer Hamza
el 16 de Sept. de 2020
See this example
y = 1:400;
x1 = 0.1*rand(size(y));
x2 = 0.1*rand(size(y))+1;
x3 = 0.1*rand(size(y))+0.4;
x4 = 0.1*rand(size(y))+1.4;
ax = axes();
hold(ax);
plot(x1, y);
plot(x2, y);
Y = [y fliplr(y)];
X = [x1 fliplr(x2)];
p = patch(X, Y, 'r', 'FaceAlpha', 0.2);
Y = [y fliplr(y)];
X = [x3 fliplr(x4)];
p = patch(X, Y, 'g', 'FaceAlpha', 0.2);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/361303/image.png)
5 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Solver Outputs and Iterative Display en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!