MATLAB: How to customize a figure toolbar by removing certain buttons

buttonbuttonsfigureMATLABmissingtoolbartooltipstring

I would like to customize the MATLAB figure window by having the ability to remove certain buttons from the figure toolbar. For instance, I do not want my figure windows to have a "Save Figure" button.

Best Answer

For releases prior to MATLAB 7.0 (R14) refer to the Related Solution listed at the bottom of the page.
For MATLAB 7.0 (R14) and all subsequent releases:
The following code will help illustrate how this can be achieved.
% If I want to disable the Save Figure button on the toolbar
figure
a = findall(gcf)
b = findall(a,'ToolTipString','Save Figure')
set(b,'Visible','Off')
FIGURE generates an empty figure window.
FINDALL gets a list of all graphics objects in the current figure window and assigns it to the variable “a”
Note that as you move your mouse across the various figure toolbar buttons, a yellow colored ToolTipString shows up indicating what each figure toolbar button does. This ToolTipString will be used to customize the figure toolbar by removing certain buttons. In the code above, we execute a second FINDALL command to find all objects assigned to the variable “a” that have the ToolTipString "Save Figure", and assign that to the variable “b”
SET sets all instances of Save Figure that are returned to “b” as OFF. These instances are no longer visible resulting in the "Save Figure" button no longer showing up in the figure toolbar.
It is extremely important that you spell the ToolTipString correctly and just as it appears when you move your mouse over a figure toolbar button. A list of ToolTipString (s) available in MATLAB 7.0.4 (R14SP2) are included below as a reference:
uipushtool buttons
(1) Show Plot Tools
(2) Hide Plot Tools
(3) Print Figure
(4) Save Figure
(5) Open File
(6) New Figure
uitoggletool buttons
(1) Insert Legend
(2) Insert Colorbar
(3) Data Cursor
(4) Rotate 3D
(5) Pan
(6) Zoom Out
(7) Zoom In
(8) Edit Plot