Effacer les filtres
Effacer les filtres

What happened to the figure toolbar? Why is it an axes toolbar? How can I put the buttons back?

137 vues (au cours des 30 derniers jours)
From R2018b onwards, tools such as the zoom, pan, datatip, etc are no longer at the toolbar at the top of the figure window. These buttons are now in an "axes" toolbar and only appear when you hover your mouse over the plot. How do I put the buttons back at the top of the figure window?

Réponse acceptée

MathWorks Support Team
MathWorks Support Team le 22 Fév 2022
Modifié(e) : MathWorks Support Team le 22 Fév 2022
From the R2018b release onwards, you can drag-to-pan and scroll-to-zoom in an axes without having to call any MATLAB functions or select any toolbar buttons. Most types of axes include a default set of built-in interactions, but you can customize them by setting the Interactions property of the axes.  For more information about controlling chart interactivity, see the following link:
You can also return the tools to the figure toolbar using the "addToolbarExplorationButtons" function. Please refer to the following code for an example:
surf(peaks)\naddToolbarExplorationButtons(gcf) % Adds buttons to figure toolbar
You can also hide or remove the axes toolbar with the code below:
ax = gca;\n\nax.Toolbar.Visible = 'off'; % Turns off the axes toolbar\n%or\nax.Toolbar = []; % Removes axes toolbar data
If you would like to ensure that figures always open with the tools in the toolbar and that axes never contain a toolbar, execute the following code:
Execute the below code if you are using R2018b or R2019a release:
Execute the below code if you are using R2019b and onwards release:
The above settings will be reset when MATLAB re-starts.  To ensure that these settings are used even after MATLAB re-starts, place the above "set" commands in a 'startup.m' file. The 'startup.m' file, when placed on the MATLAB Path, is run during the program start-up process.  For more information about 'startup.m' files, see the following link:
UPDATE (8/15/19):
Thank you for all of your comments and proposals about the axes toolbar.
We have heard your feedback and worked with members of the community on ways to improve the axes toolbar experience.  With R2019a we released several enhancements to the axes toolbar, including faster startup time, ability to hover directly over the toolbar to make it visible, and improved performance with dense surface data.  Additionally, with R2018b Update 5 we have made performance improvements to the axes toolbar startup time.  We will continue to develop enhancements to the axes toolbar experience, and would like to thank you again for your feedback to help us improve our products.
You can download the latest updates using the following link:https://www.mathworks.com/downloads/web_downloads/
  6 commentaires
Bruno Luong
Bruno Luong le 7 Jan 2019
Matlab can be weird sometimes...
Nothing is weird. The trick is tell MATLAB to regroup the outputs of commands in the cell so that MATLAB just executes them sequenctially. DISP does not return any output so it throw the error message "too many output arguments".
Rik le 7 Jan 2019
Now I get it, I was looking at it from the wrong way.
For people who made the same mistake: the error occurs because the syntax is essentially requesting a single output (even if it is only an empty []), so it is equivalent to this
function someFunction
So the error occurs because too many outputs are requested, not because there are too many returned. (Now I come to think about it, that is not how Matlab works in the first place, so that wouldn't even have made sense.)

Connectez-vous pour commenter.

Plus de réponses (2)

Yair Altman
Yair Altman le 10 Jan 2019
Modifié(e) : Yair Altman le 10 Jan 2019
For the benefit of readers who don't follow my blog, Michelle Hirsch posted the following comment yesterday, which sheds some light on the subject:
Rest assured the team is digging in to the feedback to figure out the best approach to addressing concerns.
One thing puzzles me about the whole conversation (esp. on MTLAB Answers). Nobody is mentioning the default axes interactions, which we introduced along with the axes toolbar. We actually felt this was the biggest breakthrough, because you don’t need to interact with the toolbar at all in order to zoom, pan, rotate, or add datatips to a chart. Any thoughts on this? There’s a huge banner on the figure in 18b that introduces these new gestures so we thought people would find them.
I also can clarify a couple of things from your post:
* The Toolstrip was not driven by the marketing guys (and gals!). It was very much driven by our interest in improving discoverability of key capabilities which were too buried in menus and toolbars.
* The axes toolbar was not created primarily to support the move to web graphics. We intended it to be a solution to multiple problems:
** The toolbar for a figure docked in the desktop can be very far from the figure itself.
** We’d like to move towards being able to define interactions at the axes level, instead of the figure level, since interactions are axes specific. The axes toolbar is one step in that direction
  4 commentaires
David Goodmanson
David Goodmanson le 11 Jan 2019
Hello Yair,
Could you explain where the "huge banner on the figure in 18b is?" Is the banner perhaps something that appears the first time that Matlab is invoked after download, and then not again? Maybe no one is talking about the new features because they are effectively hidden.
At any rate, documentation by banner is not what most people would call good software practice.
And in this case the regular documentation of the phantom toolbar does not work either, for a different reason: it's inaccurate. If you go to "Interactively Explore Plotted Data" it says: "Some types of interactions are enabled by default, while other types of interactions are only available through the axes toolbar. The toolbar appears at the top-right corner of the axes when you hover over it."
This is not true. It only appears when you hover the cursor over the actual plot. Then, as i mentioned in a separate comment, if you take the cursor off the plot (still in the figure window but not on the toolbar) the toolbar disappears again, intentionally taking away any visual knowledge of whether any of the toolbar zoom states are active or not. That's poor.
DGM le 10 Juin 2022
The dynamic visibility (fading effect) isn't just annoying. I will always argue that invisible elements are fundamentally the most anti-intuitive thing you could possibly incorporate into a UI. Besides that, I find that it's occasionally extremely laggy or broken. I can't count the number of times I've tried to get the axes toolbar to pop up and gotten nothing but a massive spike in CPU usage for about 10s as nothing useful happens. I end up having to click on the unresponsive axes, inadvertently adding a datatip or creating an interminable zoom box that will permanently follow the cursor until I close the figure.
Then again, prior to these changes, view controls were cumbersome to the point of ridiculousness. At least in 2D, FEX akzoom() had that solved. Now it's a weird mess of implicit and explicit controls, invisible UI elements and lag.

Connectez-vous pour commenter.

Bruno Luong
Bruno Luong le 14 Sep 2019
Duplicate my poste here
For R2019b all the tricks found previously no longer work.
I found this one does the trick
set(groot,'defaultAxesCreateFcn', ...
@(ax,varargin) start(timer('StartDelay',1,'ExecutionMode','singleShot','TimerFcn',@(varargin) axtoolbar(ax,{}))));
You might put it in startup.m file
if ~verLessThan('MATLAB','9.7')
set(groot,'defaultAxesCreateFcn', ...
@(ax,varargin) start(timer('StartDelay',1,'ExecutionMode','singleShot','TimerFcn',@(varargin) axtoolbar(ax,{}))));


En savoir plus sur Graphics Object Properties dans Help Center et File Exchange



Aucune version saisie pour le moment.

Community Treasure Hunt

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

Start Hunting!

Translated by