Colour Segments of graph
2 views (last 30 days)
Show older comments
I have plotted a voltage vs time graph and wish to colour sections of it, and want to know the best way to do this? I will attach a screenshot of the graph I have plotted and an example of how I wish to colour it.
Cheers
Answers (1)
Monisha Nalluru
on 14 Sep 2020
As an example, you can refer to the following code
x1=0:pi/20:pi;
y1=sin(x1);
patch(x1,y1,'r')
x2=pi:pi/20:2*pi;
y2=sin(x2);
patch(x2,y2,'b')
x3=2*pi:pi/20:3*pi;
y3=sin(x3);
patch(x3,y3,'y');
hold on
x=pi/60:pi/20:pi;
y=sin(x);
fill(x,y,'k') // color some red area by black
hold off
0 Comments
See Also
Categories
Find more on Polygons 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!