How do I plot many time series (iterated through in a for loop) on the same graph ?

I'm trying to do a visual comparison of a data set (n=302) on the same graph. Each file is a time series that undergoes modification within a for loop and is plotted within each iteration. Using hold hasn't been effective across iterations, and I'd like to have all of the time series plotted on the same graph. Is this possible?

3 Comments

What do you mean that "using hold hasn't been effective across iterations?"
for one iteration it's held but then figures start popping up 1 at a time with each time series plotted individually. They are never plotted on the same graph.

Sign in to comment.

 Accepted Answer

Here is a silly example of "hold on" working just fine. What are you doing differently?
figure
hold on
for i = 1:100
pause(1/i)
plot(rand(1,10))
end
(The pausing is unnecessary. It is just to show the lines getting draw one after the other.)

3 Comments

forgot to post back here. you're right-- i was holding within the for loop, which obviously didn't work. thanks so much!
Holding within the for loop should be fine. It sounds like you were putting the "figure" command in the for loop, which will generate a new figure each iteration.
Well, if he put just "hold" -- not "hold on" -- inside a for loop, it will toggle the hold on and off each iteration, and would miss all but the last plot or two.

Sign in to comment.

More Answers (0)

Categories

Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange

Asked:

on 24 Sep 2015

Commented:

on 25 Sep 2015

Community Treasure Hunt

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

Start Hunting!