How do I customize a figure toolbar by removing certain buttons?

12 vues (au cours des 30 derniers jours)
MathWorks Support Team
MathWorks Support Team le 27 Juin 2009
Commenté : Adam le 26 Fév 2020
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.

Réponse acceptée

MathWorks Support Team
MathWorks Support Team le 27 Juin 2009
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
a = findall(gcf)
b = findall(a,'ToolTipString','Save Figure')
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
  2 commentaires
Adam le 9 Mai 2019
Modifié(e) : Adam le 9 Mai 2019
Is there really still no better way to do this 10 years later? I know the figure toolbar has been removed by default, but judging from the response to that a huge number of us bring it back for our figures.
In GUIDE we can easily create a toolbar with just a selection of the toolbar options, keeping their default behaviour. Surely there must be a programmatic equivalent of this that doesn't involve individually hiding 10+ buttons (and when I tried I ended up with a rogue separator in front of my remaining buttons) via the extremely brittle approach of identifying each one by its tooltip string?!
I would have liked to have a figure with just simple zoom and pan toolbar buttons, without having to program their functionality myself in a callback.
In the end I resorted to just allowing the new default axes exploration toolbar, but this is a vastly inferior offering.
Adam le 26 Fév 2020
Then you end up with no toolbar at all!

Connectez-vous pour commenter.

Plus de réponses (0)


En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange




Community Treasure Hunt

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

Start Hunting!

Translated by