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

246 views (last 30 days)
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?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 22 Feb 2022
Edited: MathWorks Support Team on 22 Feb 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/
John on 30 Oct 2019
I’m glad to see that MathWorks is working on improvements to resolve this. I have two suggestions for improvement. The two main problems with the new toolbar are 1) it takes longer to explore figures and 2) it’s not obvious which mode you are in.
1) If I select a line and then I want to use the box zoom I have to: click on the edit arrow to de-select it, move my cursor to the other side of the figure, wait for the hover, and then click the zoom icon. This used to be a single click on the zoom icon. This problem could be easily resolved by making the toolbar visible during edit mode (hover does not work in edit mode) so that the user could click directly on the zoom icon. Also, allowing some navigation during edit mode would be nice.
2) The user cannot quickly tell if they are in edit or navigation mode (sure you can look at the icon on the toolbar and see if it’s selected, but that’s annoying). The cursor is a white arrow when I’m in navigation mode (in this mode I can roll the mouse wheel to zoom), but when I’m in edit mode I see the same white cursor arrow (in this mode rolling the mouse wheel does nothing). Previously, every action had a different cursor icon (e.g. +, -, etc.) so you knew which mode you were in, and therefore how the mouse would respond. I would suggest making a separate icon for navigation, so the user can readily see which mode they’re in.

Sign in to comment.

More Answers (5)

Michael Montouchet
Michael Montouchet on 25 Jun 2019
I am using a scatter3. It used to be very easy to rotate the things I display, now I have to use this command before being able to use the camera rotation:
It used to be simple.
Why is Matlab deleting nice features?
The reasons why Matlab is better than Python are the UI, the support, good documentation, user-friendlyness. Please continue this way and stop deleting what makes it easy. Otherwise, I would not see the point of using Matlab instead of Python.

Yair Altman
Yair Altman on 10 Jan 2019
Edited: Yair Altman on 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
DGM on 10 Jun 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.

Sign in to comment.

Scott Nuccio
Scott Nuccio on 26 Jun 2019
Edited: MathWorks Support Team on 22 Sep 2021
Here is the best I have come up with. Thought I would share.
In my startup.m file I have the following line. They overwrite the new figure functions such that everytime you create a figure, the axes toolbar is removed and my script for adding the appropriate buttons to the figures toolbar is called.
try %#ok
if ~verLessThan('matlab','9.5')
My script for adding buttons to the toolbar is called 'figToolbarFix.m' and lives in my 'user -> documents -> matlab' folder with my 'startup.m' file.
function [] = figToolbarFix(hFig)
%UNTITLED2 Summary of this function goes here
% Customize the default figure toolbar
% hFig = handle of figure to be customized
% Example: figToolbarFix(gcf);
% Example: hFig=figure; figToolbarFix(hFig);
% enable the old 'zoom', 'rotation', 'pan', 'data tips', etc., buttons
% load a pretty images to use for our buttons. Check MATLAB\release\toolbox\matlab\icons for other options, or
% make your own. Note the double conversion (rgb -> ind -> rgb) to normalize a png image.
[img1,map1] = rgb2ind(imread(fullfile(matlabroot,...
[img2,map2] = imread(fullfile(matlabroot,...
% Convert image from indexed to truecolor (want true color RGB with values of 0 to 1)
icon1 = ind2rgb(img1,map1);
icon2 = ind2rgb(img2,map2);
% Get hiddenhandle of the toolbar we want to append to. By default the 'Figure Toolbar' is the only one active
% and should be listed last assuming a new, blank figure. Use 'figure; allchild(gcf)' to show all children
hToolbar=findall(gcf, 'type', 'uitoolbar'); %hToolbar=allchild(hFig); hToolbar=hToolbar(end);
%% for Seperate property editor and plot browser buttons
% % Add a new uipushtool to the end of the toolbar.
% uipushtool(hToolbar,'CData',icon1,...
% 'TooltipString','Property Editor',...
% 'ClickedCallback','propertyeditor',...
% 'Separator','on',...
% 'HandleVisibility','off');
% % Add a new uipushtool to the end of the toolbar.
% uipushtool(hToolbar,'CData',icon2,...
% 'TooltipString','Plot Browser',...
% 'ClickedCallback','plotbrowser',...
% 'Separator','off',...
% 'HandleVisibility','off');
%% for a single toggle that opens/closes the previous state of the plot tools (use view menu to show/hide plot/browser/editor)
'TooltipString','Property Editor',...
Take and go forth!!
Also see for more info and customizations:
Good Luck
Matt J
Matt J on 12 Sep 2019
Edited: Matt J on 13 Sep 2019
A test of whether hToolbar is empty or not seems to be needed. I get frequent errors otherwise,
if ~isempty(hToolbar)
'TooltipString','Property Editor',...

Sign in to comment.

Bruno Luong
Bruno Luong on 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,{}))));
  1 Comment
thosman on 28 Sep 2019
Edited: thosman on 30 Sep 2019
Here are two additional ways to remove the toolbar in 2019b without timers. As mentioned elsewhere, place code for either method in your startup.m.
Method 1)
From playing around with removing the toolbar, I found that AxesCreateFcn method is no longer working as the cla(ax,'reset') is called after the axes is created (when hold is 'off' or the axes NextPlot property is "replace", which is the default). This resets the axes properties to their defaults (which appears to include the toolbar).
This method requires the axes to have hold on behavior by default, which bypasses the offending cla code path.
function SetDefaultFigureToolbar()
% Returns to pre-2018 style figures for all figures
% Note! This forces all axes to have hold 'on' by default
% Adds the toolbar back to the figure
% Removes the axes toolbar and interactions
% Set axes to be in hold 'on' mode by default
try %#ok
if ~verLessThan('matlab','9.5') % if matlab version >= 2018b
set(groot,'defaultAxesCreateFcn', @axDefaultCreateFcn);
set(groot, 'defaultAxesNextPlot', 'add'); % default hold 'on' behavior
function axDefaultCreateFcn(hAxes, ~)
% On axes creation, remove the toolbar and interactions.
% From:
% https://undocumentedmatlab.com/blog/improving-graphics-interactivity
hAxes.Interactions = [];
hAxes.Toolbar = [];
% ignore - old Matlab release
Method 2)
Removes the toolbar by making its default visible propery false. This method cannot remove interactions which have been shown to improve performance, but method 1 or the timer method by Bruno would allow for interaction update/removal.
set(groot, 'defaultAxesToolbarVisible', 'off')
Changes in default behavior
Finally, it is worth re-iterating that Method 1 changes default behavior by having hold on by default. Method 2 does not allow for adjustments to default interactions. Bruno's timer method should be able to accommodate both of these without changing matlab's default behavior.

Sign in to comment.

Mattiepi on 7 Apr 2020
Like so many others in this string, I find that the newest manifestation of the axes tools is buggy, and less useful than the older way of doing things. I actually appreciate the need to interact with a button (and it should be a toggle button to ensure the user knows which mode is currently "ON") rather than having the program "guess" at what I want to do. Just because I clicked doesn't mean that I need a datatip everywhere. I sincerely hope The MathWorks takes these complaints to heart and reinstates the pre-2018b method of interacting with graphs.
  1 Comment
Fernando on 8 Nov 2022
Edited: Bruno Luong on 8 Nov 2022
I can't understand how Matlab hasn't done that yet. Their slow-to-appear toolbar is an abomination.

Sign in to comment.


Find more on Graphics Object Properties in Help Center and File Exchange



No release entered yet.

Community Treasure Hunt

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

Start Hunting!

Translated by