Add the data exploration buttons back to the figure toolbar in MATLAB R2018b or larer

Posted on Sep 13, 2019

In R2018b and later, the data exploration buttons (zoom in, zoom out, etc.) were moved from the figure toolbar to the axes toolbar. I use those buttons all the time, so this change is really annoying. What is relieving is that you can use the addToolbarExplorationButtons and removeToolbarExplorationButtons functions to bring the buttons back to the figure toolbar.

fig = figure;
surf(peaks);

addToolbarExplorationButtons(fig);     % add zoom buttons to the figure toolbar
removeToolbarExplorationButtons(fig);  % Remove the buttons from the figure toolbar

The functions work for the specified figure only. If you want to open all figures with the data exploration buttons, put the following code in the startup.m

set(groot,'defaultFigureCreateFcn',@(fig,~)addToolbarExplorationButtons(fig));
set(groot,'defaultAxesCreateFcn',@(ax,~)set(ax.Toolbar,'Visible','off'));