Home > other >  How to define the matplotlib navigationtoolbar2 _init_toolbar need
How to define the matplotlib navigationtoolbar2 _init_toolbar need

Time:10-25

For help in learning, matplotlib has met a navigationtoolbar,
1 \ here is my code:
The import numpy as np
The import matplotlib. Pyplot as PLT
The from matplotlib. Ticker import FuncFormatter
The from matplotlib. Backend_bases import NavigationToolbar2
The from matplotlib. Backends. Backend_agg import FigureCanvasAgg

Data={' Barton, LLC: 109438.50, https://bbs.csdn.net/topics/
'Frami, Hills and Schmidt: 103569.59,
'Fritsch, Russell and Anderson: 112214.71,
'Jerde - Hilpert: 112591.43,
'Keeling LLC: 100934.30,
'Koepp Ltd' : 103660.54,
'Kulas Inc: 137351.96,
'Trantow - Barrows' : 123381.38,
'White - Trantow: 135841.99,
'Will LLC: 104437.60}
Group_data=https://bbs.csdn.net/topics/list (data values ())
Group_names=list (data. The keys ())
Group_mean=np. Scheme (group_data)

The class MyToolbar (NavigationToolbar2) :
Toolitems=[t for t in NavigationToolbar2 toolitems if
T [0] (the "Pan",)] in
Def __init__ (self, figure_canvas, parent=None) :
Super (MyToolbar, self) __init__ (figure_canvas)



Def select_tool (self) :
Print (" You clicked the selection tool ")


FIG, ax=PLT. Subplots ()
Canvas=FigureCanvasAgg (FIG)
The toolbar=MyToolbar (canvas)

Ax. Barh (group_names group_data)


Print (toolbar. Toolitems)
The toolbar. The update ()
PLT. The show ()

Perform the hint in NavigationToolbar2 __init__ _init_toolbar failed to perform not
There are two problems:
1, define the toolbar class have to write _init_toolbar? I checked the source code, this function is empty, only a raise error
2, the direct use matplotlib own window shows, what need to select the backend?
  • Related