Toggle visibility of plots, on the same figure?

조회 수: 81 (최근 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
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일
I'll take a look at the the guidata struct. Thanks for the leg up!

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

추가 답변 (0개)


Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기




Community Treasure Hunt

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

Start Hunting!

Translated by