Re-plotting of data on same GUI axes in matlab
4 次查看(过去 30 天)
显示 更早的评论
I am working with GUI in matlab and I have one axes to plot the data. I want to keep track what I have already plotted in order to re-plot it if needed on same axes and for this purpose, I have list box which holds names of data sets which I have plotted. I am trying to find appropriate way to select the name of data set in list box and re-plot the data set on axes. I am setting some properties of axes while plotting, so I do not not want to perform the re-plotting operation, instead, I want re-use the handle (of some kind) to get the plot data again.
I have some experience of using figure handle to get figure by providing its handle but I am looking something similar for plotting in axes.
f1 = figure
plot ([0:0.1:2*pi] , cos ([0:0.1:2*pi]))
f2 = figure
plot ([0:0.1:2*pi] , sin([0:0.1:2*pi]))
figure(f1) or figure (f2)
0 个评论
回答(1 个)
Adam
2015-6-9
编辑:Adam
2015-6-9
hPlot = plot( hAxes, [0:0.1:2*pi] , cos ([0:0.1:2*pi] );
will plot on the axes specified by hAxes (which can be acquired easily whether you are using GUIDE or just creating the axes as you go) and return the handle to the Line object of the plot in hPlot.
You can then use, e.g
set( hPlot, 'XData', 0:0.1:4*pi, 'YData', cos ([0:0.1:4*pi]) )
That is just a quick example. Personally I would factor the common 0:0.1:4*pi out into a variable, but I was following your example here!
I'm not sure what happens if you just do:
hPlot.XData = 0:0.1:4*pi;
in this case. You have to be careful when changing a property which effects others too as in a line plot it is expected that XData and YData are the same length so changing just one to a different length presumably results in a bug. I haven't tried it.
I'm not 100% clear exactly what your question was though since you talk about list boxes too, but don't appear to be asking about those.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphics Performance 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!