Use refreshdata with voronoi plots
1 回表示 (過去 30 日間)
古いコメントを表示
How can I use refreshdata to update a graph genererated with the voronoi function?
I tried:
h = voronoi(peakx,peaky,'w');
set(h,'YDataSource','peaky','XDataSource','peakx')
which I wanted to update after some calculations:
refreshdata(h,'caller')
drawnow
This does not work because voronoi has no 'YDataSource' or - 'XDataSource' property.
I also tried to:
[vx,vy] = voronoi(peakx,peaky);
h = plot(peakx,peaky,'r+',vx,vy,'b-');
followed by
set(h,'YDataSource','peaky','XDataSource','peakx')
and
refreshdata(h,'caller')
drawnow
which also does not work because the voronoi function is not updated.
Is there a way to do this?
0 件のコメント
回答 (1 件)
Agnish Dutta
2019 年 3 月 7 日
I don't think voronoi was designed to support the refreshdata workflow.
voronoi is just a function which plots and returns handles. voronoi returns a handle h(1) to the original (x,y) data (plotted as markers) and another handle h(2) to the Voronoi edge lines which depend on (x,y):
x = gallery('uniformdata',[1 10],0);
y = gallery('uniformdata',[1 10],1);
h = voronoi(x,y)
h =
2×1 graphics array:
Line
Line
If you set the data source for the original (x,y) data, the Voronoi edge lines don't react to it when you call refreshdata:
h(1).XDataSource = 'x';
h(1).YDataSource = 'y';
x = 2*x;
y = 2*y;
refreshdata % the Voronoi edge lines will be out of sync
You're better off calling voronoi again on the new data to get a plot where the lines are in sync.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Voronoi Diagram についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!