All figure windows come with a navigation toolbar, which can be used
to navigate through the data set. Here is a description of each of
the buttons at the bottom of the toolbar
Navigation Keyboard Shortcuts
| Command |
Keyboard Shortcut(s) |
| Home/Reset |
h or r or home |
| Back |
c or left arrow or backspace |
| Forward |
v or right arrow |
| Pan/Zoom |
p |
| Zoom-to-rect |
o |
| Save |
s |
| Toggle fullscreen |
f |
| Constrain pan/zoom to x axis |
hold x |
| Constrain pan/zoom to y axis |
hold y |
| Preserve aspect ratio |
hold CONTROL |
| Toggle grid |
g |
| Toggle y axis scale (log/linear) |
l |
If you are using :mod:`matplotlib.pyplot` the toolbar will be created
automatically for every figure. If you are writing your own user
interface code, you can add the toolbar as a widget. The exact syntax
depends on your UI, but we have examples for every supported UI in the
matplotlib/examples/user_interfaces directory. Here is some
example code for GTK:
from matplotlib.figure import Figure
from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg as FigureCanvas
from matplotlib.backends.backend_gtkagg import NavigationToolbar2GTKAgg as NavigationToolbar
win = gtk.Window()
win.connect("destroy", lambda x: gtk.main_quit())
win.set_default_size(400,300)
win.set_title("Embedding in GTK")
vbox = gtk.VBox()
win.add(vbox)
fig = Figure(figsize=(5,4), dpi=100)
ax = fig.add_subplot(111)
ax.plot([1,2,3])
canvas = FigureCanvas(fig) # a gtk.DrawingArea
vbox.pack_start(canvas)
toolbar = NavigationToolbar(canvas, win)
vbox.pack_start(toolbar, False, False)
win.show_all()
gtk.main()