Replot a matlab.graphics.chart
Show older comments
I have a simple issue that I could use some help with. I am preparing a loop where each cycle saves a plot in a matlab.graphics.chart. A simple code example:
x=[2 4 6 8];
y=[10 20 30 40];
plot1=plot(x,y);
How do I re-plot "plot1"? Thanks
7 Comments
KSSV
on 6 Sep 2017
Why you are worried of replotting? already you have data in hand..use plot again..
JB
on 6 Sep 2017
José-Luis
on 6 Sep 2017
plot(x,y)
You can issue the command as many times as you want.
Or do you mean to get x and y data from an existing plot?
You could also copy graphic objects, but that's a roundabout way to go about things if you do have the data.
JB
on 6 Sep 2017
JB
on 6 Sep 2017
José-Luis
on 6 Sep 2017
When you say generate one plot and store it in a data array, how do you do that?
Please show some example code.
JB
on 6 Sep 2017
Accepted Answer
More Answers (2)
plot1 is the axis handle. "re-plotting" means plotting on the same figure window with the new data.
for iCount = 1:5
x = iCount*[2 4 6 8];
y = iCount*[10 20 30 40];
h1 = figure(1); %h1 is figure handle
plot1=plot(x,y); %plot1 is axis handle
end
Categories
Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!