Use refreshdata with voronoi plots

1 Ansicht (letzte 30 Tage)
dakne
dakne am 12 Feb. 2019
Beantwortet: Agnish Dutta am 7 Mär. 2019
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?

Antworten (1)

Agnish Dutta
Agnish Dutta am 7 Mär. 2019
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.

Kategorien

Mehr zu Voronoi Diagram finden Sie in Help Center und File Exchange

Produkte


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by