MATLAB Answers

Enabling figure pan/zoom/data tips/etc. toolbar in figures

9 views (last 30 days)
Charles
Charles on 24 Mar 2020
Edited: Charles on 4 Apr 2020
Hello,
I recently upgraded to 2019b, and it seems some figure behavior has changed. I have a GUIDE application where I plot some data. Some time in 2018, I think between 2018a and 2018b, a feature was introduced where if you hovered above the upper right part of a plot, a set of buttons appeared (what is this called?).
Anyway, in the GUIDE application, these controls magically appeared and enhanced the plots immensely with no programming effort on my part. But now, in 2019b, it is not the default behavior. Can someone explain how to turn this feature on?
Thanks,
Charles Wright

  0 Comments

Sign in to comment.

Answers (1)

Harsha Priya Daggubati
Harsha Priya Daggubati on 27 Mar 2020
Hi,
You can use the following command in your GUIDE OpeningFcn .m code, to add toolbar to your axes. Here, hObject.Children is the axes object:
axtoolbar(hObject.Children,{'zoomin','zoomout','restoreview'});
But, It is suggested to migrate all your apps from GUIDE to App Designer in recent versions. For assistance in migrating your apps, use the GUIDE to App Designer Migration Tool for MATLAB. This tool is available as a support package.
Hope this helps!

  3 Comments

Charles
Charles on 30 Mar 2020
I found in my code that back in 2018 when I originally wrote the application. these lines, called in the OpeningFcn, worked perfectly well:
handles.td_axis.Toolbar.Visible='on';
handles.fd_axis.Toolbar.Visible='on';
% Update handles structure
guidata(hObject, handles);
Now they don't.
Your recommended solution (added at the same place in the code as the above) appears to work initially, and the toolbar appears in both empty graph areas. Then it disappears from one graph after the first plotting activity, then the other after another plotting activity. My solution would seem to be "run Matlab 2018b".
Rik
Rik on 30 Mar 2020
Those toolbars should not disappear. You can read this doc page for more information. If you have a specific workflow causes that to happen: try to make a MWE so we can run your code without any other dependencies and can reproduce your issue.
Charles
Charles on 4 Apr 2020
Ok, I've had time to investigate this. I decided to add the lines to make the toolbars visible part of the redisplay functions for each axis in the window (following all the plot commands). This apparently "turns on" the toolbars. I say "apparently" because when I simply print the state of the toolbar visibility, its value is always 'on', before or after the plotting activity in the axes. However, it's only after I explicitly set the visibility to 'on' that the toolbars consistently appear.
The plotting activity is nothing unusual; there's the plot command, grid, xlabel, ylabel, title, legend, a text box... nothing fancy
Anyway, I have found a workaround, and hope it continues to work.

Sign in to comment.

Sign in to answer this question.

Products


Release

R2019b