How to keep lines on a changing plot ?
古いコメントを表示
Hello,
I have an axe :
S.a_axe = axes(...);
On this axe I'm plotting some data, but I'm making it in a loop, so that every couple of seconds another data set is ploted. So the image is changing all the time. I would like to plot on it lines, but the problem is, that this lines must be always on the plot. Is there an easy way to plot lines on a plot. I mean to set them as the first seen object. Or do I have to create them always new after every plot.
Thank you, Adrien
採用された回答
その他の回答 (2 件)
Orion
2014 年 11 月 5 日
use the hold function
S.a_axe = axes();
hold on;
for i=1:10
plot(i*sin(0:0.01:10));
end
by default matlab replace the plot at each call of plot, unless you hold it.
2 件のコメント
Adrien
2014 年 11 月 5 日
Orion
2014 年 11 月 5 日
You could play with the order of the children in the axe.
% create an axe and some plots.
axes();
hold on;
for i=1:10
plot(i*100*sin(0:0.01:10));
end
pause(1)
% then add an image : will be over the lines
image(imread(which('street1.jpg')));
pause(1)
% inverse the children of the current axe
set(gca,'children',flipud(get(gca,'children')))
Mike Garrity
2014 年 11 月 5 日
Probably the simplest approach would be to save a handle to the image object and then just set its CData when you want to change the image.
h = image(first_img)
hold on
for i=1:10
plot(...)
end
pause(1)
set(h,'CData',next_img)
In this way, the order of the image won't change relative to the other things you plotted. All that's changing is the contents of the image.
カテゴリ
ヘルプ センター および File Exchange で Creating, Deleting, and Querying Graphics Objects についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!