필터 지우기
필터 지우기

Toggle visibility of plots, on the same figure?

조회 수: 88 (최근 30일)
Roger Breton
Roger Breton 2022년 1월 12일
댓글: Roger Breton 2022년 1월 12일
Attached is the current state of my "project" for which I have SO MANY questions...
First, as I experimented with the script this morning, it dawned on me that my script value would be enhanced by a checkbox that would toggle on and off the visibility of the trisurf plot, so that, I could isolate the data points from the gamut volume to better study their relationship :
Adding a uicontrol checkbox to the script should not be difficult but I sense that I would have to restructure the script very differently? Such that, from the callback function I could issue the call to the trisurf function? Or are there figure or axes options I don't know about that would make this easier?
  댓글 수: 1
Roger Breton
Roger Breton 2022년 1월 12일
A search for "Show or hide figure plot" turned the Plot Browser!!!
Wow! Thank you Mathworks, it's almost what I want, as the figure is "frozen" (can't interact with it while the Plot Browser is active). But it's mighty strong!!

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

채택된 답변

Roger Breton
Roger Breton 2022년 1월 12일
Almost there! This is what I have, now :
You can see my checkbox, top, left-hand, circled in red -- wow! I added this code to create the control :
cb = uicontrol('Style','checkbox','String','triSurf','Position',[10 500 75 150],'Value',1,'Callback',@checkBoxCallback);
cb.Visible = 'on';
Then I added this function to handle the callback :
function checkBoxCallback(source, event)
global h1;
value = get(source,'Value');
if value == 1
set(h1,'Visible','off');
else
set(h1,'Visible','on');
end
end
Problem is -- please excuse my ignorance -- the checkbox state? When the script is ran, initially, the Value = 1 option in the declaration sets the checkbox state to checked, as far as I can see. This is how the control shows up in the interface. I think it's logical to have the checkbox checked since the trisurf plot is initially visible. When I click on the ckeckbox, however, nothing happens : I have to click one more time and then, the checkbox becomes unchecked but the trisurf is still visible? It's only when I click a third time that the checkbox starts to work as 'expected'. I attached the new code. It's not the end of the world but...
One newbie question in passing, if I may...
I'm using global variables 'sparingly'... Are there better ways to do this, without getting too overly complex?
  댓글 수: 3
Roger Breton
Roger Breton 2022년 1월 12일
Right after initial launch, right after pressing the Run button, I get this :
As you can see, the checkbox is checked. Which is the expected behavior.
Now, this is what happens when I first try to uncheck :
The checkbox is unchecked -- yet, the plot is still visible?
I click the checkbox... and this is what I get :
Now the checkbox is checked YET the plot is not visible?
One more round of clicking and this is what I get :
Do you see what is going on? It is as though the checked state does not match the visibility of the plot.
I changed the initial value in the code back to 0 and changed my code in the function this way :
if value == 0
set(h1,'Visible','off');
else
set(h1,'Visible','on');
end
And now, everything is perfect!!!!
Roger Breton
Roger Breton 2022년 1월 12일
I'll take a look at the the guidata struct. Thanks for the leg up!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Visual Exploration에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by