<divid="unreleased-message"> You are reading an old version of the documentation (v3.2.0). For the latest version see <ahref="/stable/">https://matplotlib.org/stable/</a></div>
<spanid="navigation-toolbar"></span><h1>Interactive navigation<aclass="headerlink" href="#interactive-navigation" title="Permalink to this headline">¶</a></h1>
<dt>The <codeclass="docutils literal notranslate"><spanclass="pre">Home</span></code>, <codeclass="docutils literal notranslate"><spanclass="pre">Forward</span></code> and <codeclass="docutils literal notranslate"><spanclass="pre">Back</span></code> buttons</dt><dd>These are akin to a web browser's home, forward and back controls.
<codeclass="docutils literal notranslate"><spanclass="pre">Forward</span></code> and <codeclass="docutils literal notranslate"><spanclass="pre">Back</span></code> are used to navigate back and forth between
previously defined views. They have no meaning unless you have already
navigated somewhere else using the pan and zoom buttons. This is analogous
to trying to click <codeclass="docutils literal notranslate"><spanclass="pre">Back</span></code> on your web browser before visiting a
new page or <codeclass="docutils literal notranslate"><spanclass="pre">Forward</span></code> before you have gone back to a page --
nothing happens. <codeclass="docutils literal notranslate"><spanclass="pre">Home</span></code> always takes you to the
first, default view of your data. Again, all of these buttons should
feel very familiar to any user of a web browser.</dd>
<dt>The <codeclass="docutils literal notranslate"><spanclass="pre">Pan/Zoom</span></code> button</dt><dd><p>This button has two modes: pan and zoom. Click the toolbar button
to activate panning and zooming, then put your mouse somewhere
over an axes. Press the left mouse button and hold it to pan the
figure, dragging it to a new position. When you release it, the
data under the point where you pressed will be moved to the point
where you released. If you press 'x' or 'y' while panning the
motion will be constrained to the x or y axis, respectively. Press
the right mouse button to zoom, dragging it to a new position.
The x axis will be zoomed in proportionately to the rightward
movement and zoomed out proportionately to the leftward movement.
The same is true for the y axis and up/down motions. The point under your
mouse when you begin the zoom remains stationary, allowing you to
zoom in or out around that point as much as you wish. You can use the
modifier keys 'x', 'y' or 'CONTROL' to constrain the zoom to the x
axis, the y axis, or aspect ratio preserve, respectively.</p>
<p>With polar plots, the pan and zoom functionality behaves
differently. The radius axis labels can be dragged using the left
mouse button. The radius scale can be zoomed in and out using the
<dt>The <codeclass="docutils literal notranslate"><spanclass="pre">Zoom-to-rectangle</span></code> button</dt><dd>Click this toolbar button to activate this mode. Put your mouse somewhere
over an axes and press a mouse button. Define a rectangular region by
dragging the mouse while holding the button to a new location. When using
the left mouse button, the axes view limits will be zoomed to the defined
region. When using the right mouse button, the axes view limits will be
zoomed out, placing the original axes in the defined region.</dd>
<dt>The <codeclass="docutils literal notranslate"><spanclass="pre">Subplot-configuration</span></code> button</dt><dd>Use this tool to configure the appearance of the subplot:
you can stretch or compress the left, right, top, or bottom
side of the subplot, or the space between the rows or
<dt>The <codeclass="docutils literal notranslate"><spanclass="pre">Save</span></code> button</dt><dd>Click this button to launch a file save dialog. You can save
files with the following extensions: <codeclass="docutils literal notranslate"><spanclass="pre">png</span></code>, <codeclass="docutils literal notranslate"><spanclass="pre">ps</span></code>, <codeclass="docutils literal notranslate"><spanclass="pre">eps</span></code>,
<codeclass="docutils literal notranslate"><spanclass="pre">svg</span></code> and <codeclass="docutils literal notranslate"><spanclass="pre">pdf</span></code>.</dd>
<spanid="key-event-handling"></span><h2>Navigation Keyboard Shortcuts<aclass="headerlink" href="#navigation-keyboard-shortcuts" title="Permalink to this headline">¶</a></h2>
<p>The following table holds all the default keys, which can be overwritten by use of your matplotlibrc (#keymap.*).</p>
<tableborder="1" class="docutils align-default">
<colgroup>
<colwidth="41%" />
<colwidth="59%" />
</colgroup>
<theadvalign="bottom">
<trclass="row-odd"><thclass="head">Command</th>
<thclass="head">Keyboard Shortcut(s)</th>
</tr>
</thead>
<tbodyvalign="top">
<trclass="row-even"><td>Home/Reset</td>
<td><strong>h</strong> or <strong>r</strong> or <strong>home</strong></td>
</tr>
<trclass="row-odd"><td>Back</td>
<td><strong>c</strong> or <strong>left arrow</strong> or <strong>backspace</strong></td>
</tr>
<trclass="row-even"><td>Forward</td>
<td><strong>v</strong> or <strong>right arrow</strong></td>
<trclass="row-odd"><td>Constrain pan/zoom to x axis</td>
<td>hold <strong>x</strong> when panning/zooming with mouse</td>
</tr>
<trclass="row-even"><td>Constrain pan/zoom to y axis</td>
<td>hold <strong>y</strong> when panning/zooming with mouse</td>
</tr>
<trclass="row-odd"><td>Preserve aspect ratio</td>
<td>hold <strong>CONTROL</strong> when panning/zooming with mouse</td>
</tr>
<trclass="row-even"><td>Toggle major grids</td>
<td><strong>g</strong> when mouse is over an axes</td>
</tr>
<trclass="row-odd"><td>Toggle minor grids</td>
<td><strong>G</strong> when mouse is over an axes</td>
</tr>
<trclass="row-even"><td>Toggle x axis scale (log/linear)</td>
<td><strong>L</strong> or <strong>k</strong> when mouse is over an axes</td>
</tr>
<trclass="row-odd"><td>Toggle y axis scale (log/linear)</td>
<td><strong>l</strong> when mouse is over an axes</td>
</tr>
</tbody>
</table>
<p>If you are using <aclass="reference internal" href="../api/_as_gen/matplotlib.pyplot.html#module-matplotlib.pyplot" title="matplotlib.pyplot"><codeclass="xref py py-mod docutils literal notranslate"><spanclass="pre">matplotlib.pyplot</span></code></a> 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
<codeclass="docutils literal notranslate"><spanclass="pre">matplotlib/examples/user_interfaces</span></code> directory. Here is some
<spanclass="n">win</span><spanclass="o">.</span><spanclass="n">set_title</span><spanclass="p">(</span><spanclass="s2">"Embedding in GTK"</span><spanclass="p">)</span>
<spanclass="n">canvas</span><spanclass="o">=</span><spanclass="n">FigureCanvas</span><spanclass="p">(</span><spanclass="n">fig</span><spanclass="p">)</span><spanclass="c1"># a Gtk.DrawingArea</span>