Plot handle to return single object
2 次查看(过去 30 天)
显示 更早的评论
Hi,
i'm building a GUI where I'm supposed to turn on or off the Visibility of multiple plots.
So far, what i'm doing is to get the handle of the plot and then toggle the Visibility property.
hraw=plot(cur_axes,time(1:test_plot_range),raw_signal(1:test_plot_range),linetype);
hraw.Visible='on';
For the majority of the plots, i get a handle [1×1 Line].
However, there are cases where the returned handle consists of all the line points [1041×1 Line].
hraw_mean=plot(cur_axes,cur_struct.time(1:test_plot_range),raw_mean*ones(test_plot_range),'m-','MarkerSize',cell2mat(signal_struct.params(4)));
Please note that "hraw_mean" refers to a straight line, where the "hraw" handler refers to random signals (not straight lines).
A workaround would be to loop through all points and toggle their visibility ( indexing with : -e.g. hraw_mean(:) raises an error), but I'd prefer a more elegant way (i.e. return a single sized handler).
Are there any suggestions?
Thank you in advance
Markos
0 个评论
采纳的回答
Praveen Iyyappan Valsala
2019-11-15
You can use set function.
hraw_mean.set('Visible','off');
That sets Visible proptery of all cells to off. If you want to set a property for some cells only.
hraw_mean([1:3 7 8]).set('Visible','off');
3 个评论
Praveen Iyyappan Valsala
2019-11-16
It is because of your input data. ones(size) gives you sqare matrix of dimension size X size
raw_mean*ones(test_plot_range)
Generate 1D array instead
raw_mean*ones(1,test_plot_range)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!