필터 지우기
필터 지우기

Use refreshdata with voronoi plots

조회 수: 1 (최근 30일)
dakne
dakne 2019년 2월 12일
답변: Agnish Dutta 2019년 3월 7일
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?

답변 (1개)

Agnish Dutta
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.

카테고리

Help CenterFile Exchange에서 Voronoi Diagram에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by