フィルターのクリア

How to best update filled area 2D plot?

2 ビュー (過去 30 日間)
Steven Terrana
Steven Terrana 2015 年 3 月 1 日
回答済み: Steven Terrana 2015 年 3 月 4 日
Hello,
I am creating an animation in which an animated line travels across the figure window.
When this line crosses through predefined bounds, I need to make an area object update in real time concurrently with the animated line.
My problem is when the second area plot is created, it changes the colors of the previous area plot as well as connects their edges.
An example of the problem looks like this: When i try to update the bounds of the furthest right area plot, the following occurs.
Then, i update the XData and YData properties of that area object and the following occurs
I am positive that my new XData and YData vectors are the appropriate sizes/values.
I have tried deleting the object and remaking it, but this does not flow smoothly.
Any help would be appreciated as to why this is happening.
Thanks for your time!
Steven.
  2 件のコメント
Image Analyst
Image Analyst 2015 年 3 月 2 日
Are you using the animatedline() function? Where's your code? Are you changing colormaps at any time?
Steven Terrana
Steven Terrana 2015 年 3 月 3 日
編集済み: Steven Terrana 2015 年 3 月 3 日
animatedline() is being drawn to draw the line, the problem seems to be entirely in the updating of the area's bounds. The face color of each area is either [0.7 0 0] or [0 0.3 0], and they have been made partially transparent.
An example of code that gives me the same problem is:
figure;
x = 0:10;
y = 10*x;
plot(x,y), hold on
a1 = area(2:4,100*ones(1,length(2:4)),'FaceColor',[0 0.3 0]); drawnow;
set(a1.Face,'ColorType','truecoloralpha')
a1.Face.ColorData(4)=45;
a2 = area(7:8,100*ones(1,length(7:8)),'FaceColor',[0.7 0 0]); drawnow;
set(a2.Face,'ColorType','truecoloralpha')
a2.Face.ColorData(4)=45;
pause(1)
for i = 8:0.1:10
a2.XData = 7:0.1:i;
a2.YData = 100 * ones(1,length(a2.XData));
drawnow
pause(0.1)
end

サインインしてコメントする。

採用された回答

Steven Terrana
Steven Terrana 2015 年 3 月 4 日
Hello,
I have found a solution to my problem.
constantly deleting and recreating a patch object with the appropriate properties is fast enough for animation whereas doing the same thing with an area object is too cumbersome and leads to a discretized representation.
thanks!

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnimation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by