How to fill the area between two function on a plot with transparent colour?
18 views (last 30 days)
Show older comments
Is it possible to fill the area between two function on a plot with transparent colour?
0 Comments
Accepted Answer
Mischa Kim
on 21 Apr 2015
It is. Try, e.g.
d = 0.1;
x = linspace(0,1,20);
z = d*x.^2;
fill([x flip(x)],[z zeros(size(z))],'k','LineStyle','none')
hold on
plot(x,z,'k-');
alpha(0.25)
grid
2 Comments
Ruoyao
on 29 Sep 2017
Thank you Mischa, your answer was very helpful! Then I added the legend, but the colors in the legend were still solid. How could I make them transparent as well? Thanks!
Ruoyao
on 29 Sep 2017
Edited: Ruoyao
on 29 Sep 2017
I found answer on this webpage: https://stackoverflow.com/questions/23693210/setting-the-alpha-value-transparency-of-legend-to-match-alpha-in-plot-in-matla
More Answers (0)
See Also
Categories
Find more on Lighting, Transparency, and Shading 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!