Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Removing figureoptions from subclassed NavigationToolbar2QT #4574

Closed
Milestone
@ghost

Description

Subclassing a NavigationToolbar2QT allows one to add and remove buttons on the navigation bar. However, the figure options menu remains and cannot be removed like the other default buttons. I was able to construct a temporary solution by importingmatplotlib.backends.backend_qt and settingfigureoptions = None. Please see below example:

from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTimport matplotlib.backends.backend_qt5 as backendclass MplToolbar(NavigationToolbar2QT):    def __init__(self, canvas_, parent_):        backend.figureoptions = None  # Monkey patched to kill the figure options button on matplotlib toolbar        self.toolitems = (            ('Home', 'Reset original view', 'home', 'home'),            ('Back', 'Back to previous view', 'back', 'back'),            ('Forward', 'Forward to next view', 'forward', 'forward'),            (None, None, None, None),            ('Pan', 'Pan axes with left mouse, zoom with right', 'move', 'pan'),            ('Zoom', 'Zoom to rectangle', 'zoom_to_rect', 'zoom'),            (None, None, None, None),            ('Save', 'Save the current image', 'filesave', 'save_figure'),            )        NavigationToolbar2QT.__init__(self, canvas_, parent_)

Is there another, better solution out there? Appreciated!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp