Plot handle to return single object

조회 수: 1 (최근 30일)
Markos Sigalas
Markos Sigalas 2019년 11월 15일
댓글: Markos Sigalas 2019년 11월 16일
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

채택된 답변

Praveen Iyyappan Valsala
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
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)
Markos Sigalas
Markos Sigalas 2019년 11월 16일
You're so right.
Thank you very much.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Plot Customization에 대해 자세히 알아보기

태그

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by