Setting plot handle x,y,z data does not clear "old data"
Show older comments
I am plotting information streaming in from a file. Instead of plotting the new data every time, I'm trying to be "efficient" by updating the XData, YData, and ZData with the SET command. I am also trying to to manipulate the data as it is streaming in by doing things like changing the plot marker or filtering the data and only displaying certain data points. Again, all on the fly.
My problem is that when I try to update the symbology, for example, the old markers remain on the plot with the new markers overlaid on top of the old. If I try to filter the data, new data is filtered, and will display when the filter is removed, but old data (that should be filtered) stays on the plot.
I try to clear the data by using
set(plotHandle,'XData',[],'YData',[],'ZData',[]);
to no avail. (I update the data fields with another "set" command later and call "drawnow" when I'm ready to render the plot again.) I could use
cla
but that would cause me to lose the handle all together and I would have to plot the data again, which I am trying to avoid.
Any suggestions?
12 Comments
Geoff Hayes
on 17 Jan 2015
Ryan - are you sure that the old markers were created using plotHandle and not some other handle (that may or may not captured)? What are the different commands that you are using to update your figure (with graphics)?
Ryan
on 17 Jan 2015
Geoff Hayes
on 17 Jan 2015
So do all of your plots (or whatever else you are using to add graphics to the axes) make use of plotHandle? Are you sure that there isn't another handle being used?
Ryan
on 17 Jan 2015
Geoff Hayes
on 17 Jan 2015
Could you post a sample of the code, or at the very least, make a list of all the calls to plot and ensure that in each call, you are saving the handle to it. Once you have saved the handle, how do you pass it around? It sounds like you may have a GUI of some kind (is this the case?) so what are you using to keep track of all the handles returned from plot?
Image Analyst
on 18 Jan 2015
This does not seem like it needs extreme speed. Why can't you just plot it all over again to update it? I mean, how much time would that take? I would think it would take only a fraction of a second like most calls to plot(). Does it take longer, like several seconds?
Ryan
on 18 Jan 2015
Ryan
on 18 Jan 2015
Geoff Hayes
on 18 Jan 2015
Ryan - I don't understand the second condition in your if statement
|| isempty(deltaReturns)
which, when true, means that even if your h_delta is a valid handle to a graphics object, you will overwrite it with a new handle...and so the old one persists. You may want to add some additional code here to separate these two conditions so that if you have a handle AND the deltaReturns is empty the delete the existing handle before calling plot3.
Ryan
on 18 Jan 2015
Image Analyst
on 18 Jan 2015
If Geoff posts it as an answer, I can delete my answer so that you can accept Geoff's answer and he can get reputation points.
Geoff Hayes
on 18 Jan 2015
@Ryan - I've never had to work with that much data (at any one time) so would not be able to provide a clear idea of what the performance impact may be. I still think that if there is data that you are not ever going to use (because it is out of date or whatever) then for sure delete it from your displays.
Accepted Answer
More Answers (0)
Categories
Find more on Graphics Performance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!