Filling area between lines with color
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Sebastian Daneli
am 18 Aug. 2021
Bearbeitet: Yazan
am 18 Aug. 2021
I have this figure:
And I wish to fill the area between the two straight lines with a color. I've looked around and tried fill and patch, but they don't seem to work with my straight lines? The straight lines are created by:
Line1=0.1*ones(length(signal),1);
Line2=-Line1;
Any ideas what the problem is and how to solve it?
Akzeptierte Antwort
Wan Ji
am 18 Aug. 2021
Bearbeitet: Wan Ji
am 18 Aug. 2021
If your horizontal coordinates is t array, then patch or fill can help
maxTime = max(t(:));
patch([0, maxTime, maxTime, 0], [-0.1, -0.1, 0.1, 0.1], 'r', 'facealpha', 0.3, 'edgecolor','none')
Or fill command
maxTime = max(t(:));
fill([0, maxTime, maxTime, 0], [-0.1, -0.1, 0.1, 0.1], 'r', 'facealpha', 0.3, 'edgecolor','none')
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Annotations 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!