HOW CAN I PLOT MULTIPLE VERTICAL LINE ON THIS FIGURE

2 views (last 30 days)
I am try to cut the curve by several vertical lines. is there any way to approach. here is my data base.
format short g;
plot(Time_s,DO2,Loggingstart,100 )
xlabel('time(s)');
ylabel('DO2%');
grid on
grid minor
hold on
plot(Loggingstart,[0 100],'r*',Loggingstop,[0 100],'g*')

Answers (1)

dpb
dpb on 24 Feb 2015
Edited: dpb on 25 Feb 2015
One of the more efficient ways to draw multiple lines is to build the x,y vectors separating the line end points with NaN. This causes the handle graphics routines such as plot line to break the drawn line(s) at those points...trivial example--
>> axes
>> x=[.1 .1 nan .2 .2 nan .3 .3 nan .8 .8].';
y=[repmat([0 1 nan].',3,1); 0; 1];
>> line(x,y)
>> xlim([0 1])
ADDENDUM
But, for your example problem, with different colors per line, the plot call is ok since the color is a property of the line and the above form creates one line with breaks. Efficient in terms of preventing the proliferation of objects/handles, but need them to have separate properties.
plot([Loggingstart Loggingstart],[0 100],'r*', ...
[Loggingstop, Loggingstop], [0 100],'g*')
  2 Comments
yang zhan
yang zhan on 24 Feb 2015
what if i wanna draw the line on a data from Loggingstart
dpb
dpb on 24 Feb 2015
Edited: dpb on 24 Feb 2015
What if you do? Build the x,y coordinate vectors as needed...to draw a line you need a start:end coordinate for each line as shown above. For vertical lines, the x-coordinates are the same and the y are the two limits. Obviously, for horizontal that's reversed; for general line the coordinates are whatever they needs must be.

Sign in to comment.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!