How to modify the navigation toolbar easily in a matplotlib figure window?

Is it possible to do something like the following to modify the navigation toolbar in matplotlib?

  1. Generate a figure window, such as by fig = figure()
  2. Get a reference of the navigation toolbar, such as by tbar = fig.get_navigation_toolbar() or better yet, just by tbar = fig.navtbar
  3. Modify the toolbar through the reference tbar, such as delete/add/edit a button by something like this: tbar.add_button(), tbar.remove_button(a reference to a button), tbar.edit_button(a reference to a button).
  4. Update the figure by fig.canvas.draw()
    Thank you very much.

Is it possible to do something like the following to modify the
navigation toolbar in matplotlib?

1. Generate a figure window, such as by *fig = figure()*
2. Get a reference of the navigation toolbar, such as by *tbar =
    fig.get_navigation_toolbar()* or better yet, just by *tbar =
    fig.navtbar*
3. Modify the toolbar through the reference /tbar/, such as
    delete/add/edit a button by something like this:
    *tbar.add_button()*, *tbar.remove_button(a reference to a button)*,
      *tbar.edit_button(a reference to a button)*.
4. Update the figure by *fig.canvas.draw()*

No, this sort of flexibility has been at least on the mental wish-list for a long time, but it is not available. It would require substantial work on all of the gui backends.

Eric

···

On 2012/10/02 8:08 AM, Jianbao Tao wrote:

Thank you very much.

------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

Note, however, code has been improved for the 1.2.0 release to make it easier to modify the set of buttons that are used. In backend_bases.py, look for the NavigationToolbar2 class.

Cheers!

Ben Root

···

On Tue, Oct 2, 2012 at 2:34 PM, Eric Firing <efiring@…202…> wrote:

On 2012/10/02 8:08 AM, Jianbao Tao wrote:

Is it possible to do something like the following to modify the

navigation toolbar in matplotlib?

  1. Generate a figure window, such as by fig = figure()
  1. Get a reference of the navigation toolbar, such as by tbar =
    fig.get_navigation_toolbar()
    or better yet, just by *tbar =
fig.navtbar*
  1. Modify the toolbar through the reference /tbar/, such as
    delete/add/edit a button by something like this:
*tbar.add_button()*,  *tbar.remove_button(a reference to a button)*,
  *tbar.edit_button(a reference to a button)*.
  1. Update the figure by fig.canvas.draw()

No, this sort of flexibility has been at least on the mental wish-list

for a long time, but it is not available. It would require substantial

work on all of the gui backends.

Eric

Note, however, code has been improved for the 1.2.0 release to make it easier to modify the set of buttons that are used. In backend_bases.py,
look for the NavigationToolbar2 class.

Ah yes! I knew I did that for a good reason. :slight_smile: Good thinking Ben!