You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
<divid="unreleased-message"> You are reading an old version of the documentation (v2.0.0). For the latest version see <ahref="https://matplotlib.org/stable/faq/howto_faq.html">https://matplotlib.org/stable/faq/howto_faq.html</a></div>
<li><aclass="reference internal" href="#save-multiple-plots-to-one-pdf-file">Save multiple plots to one pdf file</a></li>
<li><aclass="reference internal" href="#move-the-edge-of-an-axes-to-make-room-for-tick-labels">Move the edge of an axes to make room for tick labels</a></li>
<li><aclass="reference internal" href="#automatically-make-room-for-tick-labels">Automatically make room for tick labels</a></li>
<li><aclass="reference internal" href="#configure-the-tick-linewidths">Configure the tick linewidths</a></li>
<li><aclass="reference internal" href="#align-my-ylabels-across-multiple-subplots">Align my ylabels across multiple subplots</a></li>
<li><aclass="reference internal" href="#skip-dates-where-there-is-no-data">Skip dates where there is no data</a></li>
<li><aclass="reference internal" href="#control-the-depth-of-plot-elements">Control the depth of plot elements</a></li>
<li><aclass="reference internal" href="#make-the-aspect-ratio-for-plots-equal">Make the aspect ratio for plots equal</a></li>
<li><aclass="reference internal" href="#find-all-objects-in-a-figure-of-a-certain-type" id="id5">Find all objects in a figure of a certain type</a></li>
<li><aclass="reference internal" href="#how-to-prevent-ticklabels-from-having-an-offset" id="id6">How to prevent ticklabels from having an offset</a></li>
<li><aclass="reference internal" href="#save-multiple-plots-to-one-pdf-file" id="id8">Save multiple plots to one pdf file</a></li>
<li><aclass="reference internal" href="#move-the-edge-of-an-axes-to-make-room-for-tick-labels" id="id9">Move the edge of an axes to make room for tick labels</a></li>
<li><aclass="reference internal" href="#automatically-make-room-for-tick-labels" id="id10">Automatically make room for tick labels</a></li>
<li><aclass="reference internal" href="#configure-the-tick-linewidths" id="id11">Configure the tick linewidths</a></li>
<li><aclass="reference internal" href="#align-my-ylabels-across-multiple-subplots" id="id12">Align my ylabels across multiple subplots</a></li>
<li><aclass="reference internal" href="#skip-dates-where-there-is-no-data" id="id13">Skip dates where there is no data</a></li>
<li><aclass="reference internal" href="#control-the-depth-of-plot-elements" id="id14">Control the depth of plot elements</a></li>
<li><aclass="reference internal" href="#make-the-aspect-ratio-for-plots-equal" id="id15">Make the aspect ratio for plots equal</a></li>
<li><aclass="reference internal" href="#generate-images-without-having-a-window-appear" id="id17">Generate images without having a window appear</a></li>
<spanid="howto-datetime64"></span><h3>Plot <codeclass="xref py py-obj docutils literal"><spanclass="pre">numpy.datetime64</span></code> values<aclass="headerlink" href="#plot-numpy-datetime64-values" title="Permalink to this headline">¶</a></h3>
<p>For Matplotlib to plot dates (or any scalar with units) a converter
to float needs to be registered with the <codeclass="xref py py-obj docutils literal"><spanclass="pre">matplolib.units</span></code> module. The
current best converters for <codeclass="xref py py-obj docutils literal"><spanclass="pre">datetime64</span></code> values are in <codeclass="xref py py-obj docutils literal"><spanclass="pre">pandas</span></code>. Simply
<p>If you only want to use the <codeclass="xref py py-obj docutils literal"><spanclass="pre">pandas</span></code> converter for <codeclass="xref py py-obj docutils literal"><spanclass="pre">datetime64</span></code> values</p>
<spanid="howto-findobj"></span><h3>Find all objects in a figure of a certain type<aclass="headerlink" href="#find-all-objects-in-a-figure-of-a-certain-type" title="Permalink to this headline">¶</a></h3>
<p>Every Matplotlib artist (see <aclass="reference internal" href="../users/artists.html#artist-tutorial"><spanclass="std std-ref">Artist tutorial</span></a>) has a method
called <aclass="reference internal" href="../api/_as_gen/matplotlib.artist.Artist.findobj.html#matplotlib.artist.Artist.findobj" title="matplotlib.artist.Artist.findobj"><codeclass="xref py py-meth docutils literal"><spanclass="pre">findobj()</span></code></a> that can be used to
recursively search the artist for any artists it may contain that meet
some criteria (e.g., match all <aclass="reference internal" href="../api/lines_api.html#matplotlib.lines.Line2D" title="matplotlib.lines.Line2D"><codeclass="xref py py-class docutils literal"><spanclass="pre">Line2D</span></code></a>
instances or match some arbitrary filter function). For example, the
following snippet finds every object in the figure which has a
<codeclass="xref py py-obj docutils literal"><spanclass="pre">set_color</span></code> property and makes the object blue:</p>
<spanid="howto-supress-offset"></span><h3>How to prevent ticklabels from having an offset<aclass="headerlink" href="#how-to-prevent-ticklabels-from-having-an-offset" title="Permalink to this headline">¶</a></h3>
<p>The default formatter will use an offset to reduce
the length of the ticklabels. To turn this feature
<spanid="howto-transparent"></span><h3>Save transparent figures<aclass="headerlink" href="#save-transparent-figures" title="Permalink to this headline">¶</a></h3>
<p>The <aclass="reference internal" href="../api/pyplot_api.html#matplotlib.pyplot.savefig" title="matplotlib.pyplot.savefig"><codeclass="xref py py-meth docutils literal"><spanclass="pre">savefig()</span></code></a> command has a keyword argument
<em>transparent</em> which, if ‘True’, will make the figure and axes
backgrounds transparent when saving, but will not affect the displayed
image on the screen.</p>
<p>If you need finer grained control, e.g., you do not want full transparency
or you want to affect the screen displayed version as well, you can set
<spanid="howto-multipage"></span><h3>Save multiple plots to one pdf file<aclass="headerlink" href="#save-multiple-plots-to-one-pdf-file" title="Permalink to this headline">¶</a></h3>
<p>Many image file formats can only have one image per file, but some
formats support multi-page files. Currently only the pdf backend has
support for this. To make a multi-page pdf file, first initialize the
<p>You can give the <aclass="reference internal" href="../api/backend_pdf_api.html#matplotlib.backends.backend_pdf.PdfPages" title="matplotlib.backends.backend_pdf.PdfPages"><codeclass="xref py py-class docutils literal"><spanclass="pre">PdfPages</span></code></a>
object to <aclass="reference internal" href="../api/pyplot_api.html#matplotlib.pyplot.savefig" title="matplotlib.pyplot.savefig"><codeclass="xref py py-func docutils literal"><spanclass="pre">savefig()</span></code></a>, but you have to specify
<spanid="howto-subplots-adjust"></span><h3>Move the edge of an axes to make room for tick labels<aclass="headerlink" href="#move-the-edge-of-an-axes-to-make-room-for-tick-labels" title="Permalink to this headline">¶</a></h3>
<p>For subplots, you can control the default spacing on the left, right,
bottom, and top as well as the horizontal and vertical spacing between
multiple rows and columns using the
<aclass="reference internal" href="../api/figure_api.html#matplotlib.figure.Figure.subplots_adjust" title="matplotlib.figure.Figure.subplots_adjust"><codeclass="xref py py-meth docutils literal"><spanclass="pre">matplotlib.figure.Figure.subplots_adjust()</span></code></a> method (in pyplot it
is <aclass="reference internal" href="../api/pyplot_api.html#matplotlib.pyplot.subplots_adjust" title="matplotlib.pyplot.subplots_adjust"><codeclass="xref py py-func docutils literal"><spanclass="pre">subplots_adjust()</span></code></a>). For example, to move
the bottom of the subplots up to make room for some rotated x tick
<p>You can control the defaults for these parameters in your
<codeclass="file docutils literal"><spanclass="pre">matplotlibrc</span></code> file; see <aclass="reference internal" href="../users/customizing.html#customizing-matplotlib"><spanclass="std std-ref">Customizing matplotlib</span></a>. For
example, to make the above setting permanent, you would set:</p>
<divclass="highlight-default"><divclass="highlight"><pre><span></span><spanclass="n">figure</span><spanclass="o">.</span><spanclass="n">subplot</span><spanclass="o">.</span><spanclass="n">bottom</span><spanclass="p">:</span><spanclass="mf">0.2</span><spanclass="c1"># the bottom of the subplots of the figure</span>
</pre></div>
</div>
<p>The other parameters you can configure are, with their defaults</p>
<dlclass="docutils">
<dt><em>left</em> = 0.125</dt>
<dd>the left side of the subplots of the figure</dd>
<dt><em>right</em> = 0.9</dt>
<dd>the right side of the subplots of the figure</dd>
<dt><em>bottom</em> = 0.1</dt>
<dd>the bottom of the subplots of the figure</dd>
<dt><em>top</em> = 0.9</dt>
<dd>the top of the subplots of the figure</dd>
<dt><em>wspace</em> = 0.2</dt>
<dd>the amount of width reserved for blank space between subplots,
expressed as a fraction of the average axis width</dd>
<dt><em>hspace</em> = 0.2</dt>
<dd>the amount of height reserved for white space between subplots,
expressed as a fraction of the average axis height</dd>
</dl>
<p>If you want additional control, you can create an
<aclass="reference internal" href="../api/axes_api.html#matplotlib.axes.Axes" title="matplotlib.axes.Axes"><codeclass="xref py py-class docutils literal"><spanclass="pre">Axes</span></code></a> using the
<aclass="reference internal" href="../api/figure_api.html#matplotlib.figure.Figure.add_axes" title="matplotlib.figure.Figure.add_axes"><codeclass="xref py py-meth docutils literal"><spanclass="pre">add_axes()</span></code></a> method), which allows you to
<p>where all values are in fractional (0 to 1) coordinates. See
<aclass="reference internal" href="../examples/pylab_examples/axes_demo.html#pylab-examples-axes-demo"><spanclass="std std-ref">pylab_examples example code: axes_demo.py</span></a> for an example of placing axes manually.</p>
<spanid="howto-auto-adjust"></span><h3>Automatically make room for tick labels<aclass="headerlink" href="#automatically-make-room-for-tick-labels" title="Permalink to this headline">¶</a></h3>
<divclass="admonition note">
<pclass="first admonition-title">Note</p>
<p>This is now easier to handle than ever before.
Calling <aclass="reference internal" href="../api/pyplot_api.html#matplotlib.pyplot.tight_layout" title="matplotlib.pyplot.tight_layout"><codeclass="xref py py-func docutils literal"><spanclass="pre">tight_layout()</span></code></a> can fix many common
layout issues. See the <aclass="reference internal" href="../users/tight_layout_guide.html#plotting-guide-tight-layout"><spanclass="std std-ref">Tight Layout guide</span></a>.</p>
<pclass="last">The information below is kept here in case it is useful for other
purposes.</p>
</div>
<p>In most use cases, it is enough to simply change the subplots adjust
parameters as described in <aclass="reference internal" href="#howto-subplots-adjust"><spanclass="std std-ref">Move the edge of an axes to make room for tick labels</span></a>. But in some
cases, you don’t know ahead of time what your tick labels will be, or
how large they will be (data and labels outside your control may be
being fed into your graphing application), and you may need to
automatically adjust your subplot parameters based on the size of the
tick labels. Any <aclass="reference internal" href="../api/text_api.html#matplotlib.text.Text" title="matplotlib.text.Text"><codeclass="xref py py-class docutils literal"><spanclass="pre">Text</span></code></a> instance can report
its extent in window coordinates (a negative x coordinate is outside
the window), but there is a rub.</p>
<p>The <aclass="reference internal" href="../api/backend_bases_api.html#matplotlib.backend_bases.RendererBase" title="matplotlib.backend_bases.RendererBase"><codeclass="xref py py-class docutils literal"><spanclass="pre">RendererBase</span></code></a> instance, which is
used to calculate the text size, is not known until the figure is
drawn (<aclass="reference internal" href="../api/figure_api.html#matplotlib.figure.Figure.draw" title="matplotlib.figure.Figure.draw"><codeclass="xref py py-meth docutils literal"><spanclass="pre">draw()</span></code></a>). After the window is
drawn and the text instance knows its renderer, you can call
<aclass="reference internal" href="../api/text_api.html#matplotlib.text.Text.get_window_extent" title="matplotlib.text.Text.get_window_extent"><codeclass="xref py py-meth docutils literal"><spanclass="pre">get_window_extent()</span></code></a>. One way to solve
this chicken and egg problem is to wait until the figure is draw by
connecting
(<aclass="reference internal" href="../api/backend_bases_api.html#matplotlib.backend_bases.FigureCanvasBase.mpl_connect" title="matplotlib.backend_bases.FigureCanvasBase.mpl_connect"><codeclass="xref py py-meth docutils literal"><spanclass="pre">mpl_connect()</span></code></a>) to the
“on_draw” signal (<aclass="reference internal" href="../api/backend_bases_api.html#matplotlib.backend_bases.DrawEvent" title="matplotlib.backend_bases.DrawEvent"><codeclass="xref py py-class docutils literal"><spanclass="pre">DrawEvent</span></code></a>) and
get the window extent there, and then do something with it, e.g., move
the left of the canvas over; see <aclass="reference internal" href="../users/event_handling.html#event-handling-tutorial"><spanclass="std std-ref">Event handling and picking</span></a>.</p>
<p>Here is an example that gets a bounding box in relative figure coordinates
(0..1) of each of the labels and uses it to move the left of the subplots
over so that the tick labels fit in the figure</p>
<spanclass="n">fig</span><spanclass="o">.</span><spanclass="n">subplots_adjust</span><spanclass="p">(</span><spanclass="n">left</span><spanclass="o">=</span><spanclass="mf">1.1</span><spanclass="o">*</span><spanclass="n">bbox</span><spanclass="o">.</span><spanclass="n">width</span><spanclass="p">)</span><spanclass="c1"># pad a little</span>
<spanid="howto-ticks"></span><h3>Configure the tick linewidths<aclass="headerlink" href="#configure-the-tick-linewidths" title="Permalink to this headline">¶</a></h3>
<p>In Matplotlib, the ticks are <em>markers</em>. All
<aclass="reference internal" href="../api/lines_api.html#matplotlib.lines.Line2D" title="matplotlib.lines.Line2D"><codeclass="xref py py-class docutils literal"><spanclass="pre">Line2D</span></code></a> objects support a line (solid,
dashed, etc) and a marker (circle, square, tick). The tick linewidth
is controlled by the “markeredgewidth” property:</p>
<spanid="howto-align-label"></span><h3>Align my ylabels across multiple subplots<aclass="headerlink" href="#align-my-ylabels-across-multiple-subplots" title="Permalink to this headline">¶</a></h3>
<p>If you have multiple subplots over one another, and the y data have
different scales, you can often get ylabels that do not align
vertically across the multiple subplots, which can be unattractive.
By default, Matplotlib positions the x location of the ylabel so that
it does not overlap any of the y ticks. You can override this default
behavior by specifying the coordinates of the label. The example
below shows the default behavior in the left subplots, and the manual
<spanclass="n">ax1</span><spanclass="o">.</span><spanclass="n">set_title</span><spanclass="p">(</span><spanclass="s1">'ylabels not aligned'</span><spanclass="p">)</span>
<spanid="date-index-plots"></span><h3>Skip dates where there is no data<aclass="headerlink" href="#skip-dates-where-there-is-no-data" title="Permalink to this headline">¶</a></h3>
<p>When plotting time series, e.g., financial time series, one often wants
to leave out days on which there is no data, e.g., weekends. By passing
in dates on the x-xaxis, you get large horizontal gaps on periods when
there is not data. The solution is to pass in some proxy x-data, e.g.,
evenly sampled indices, and then use a custom formatter to format
these as dates. The example below shows how to use an ‘index formatter’
<spanclass="n">r</span><spanclass="o">=</span><spanclass="n">r</span><spanclass="p">[</span><spanclass="o">-</span><spanclass="mi">30</span><spanclass="p">:]</span><spanclass="c1"># get the last 30 days</span>
<spanid="howto-set-zorder"></span><h3>Control the depth of plot elements<aclass="headerlink" href="#control-the-depth-of-plot-elements" title="Permalink to this headline">¶</a></h3>
<p>Within an axes, the order that the various lines, markers, text,
See <aclass="reference internal" href="../examples/pylab_examples/zorder_demo.html#pylab-examples-zorder-demo"><spanclass="std std-ref">pylab_examples example code: zorder_demo.py</span></a> for a complete example.<p>You can also use the Axes property
<aclass="reference internal" href="../api/_as_gen/matplotlib.axes.Axes.set_axisbelow.html#matplotlib.axes.Axes.set_axisbelow" title="matplotlib.axes.Axes.set_axisbelow"><codeclass="xref py py-meth docutils literal"><spanclass="pre">set_axisbelow()</span></code></a> to control whether the grid
lines are placed above or below your other plot elements.</p>
<spanid="howto-axis-equal"></span><h3>Make the aspect ratio for plots equal<aclass="headerlink" href="#make-the-aspect-ratio-for-plots-equal" title="Permalink to this headline">¶</a></h3>
See <aclass="reference internal" href="../examples/pylab_examples/equal_aspect_ratio.html#pylab-examples-equal-aspect-ratio"><spanclass="std std-ref">pylab_examples example code: equal_aspect_ratio.py</span></a> for a complete example.</div>
<divclass="section" id="multiple-y-axis-scales">
<spanid="howto-twoscale"></span><h3>Multiple y-axis scales<aclass="headerlink" href="#multiple-y-axis-scales" title="Permalink to this headline">¶</a></h3>
<p>A frequent request is to have two scales for the left and right
y-axis, which is possible using <aclass="reference internal" href="../api/pyplot_api.html#matplotlib.pyplot.twinx" title="matplotlib.pyplot.twinx"><codeclass="xref py py-func docutils literal"><spanclass="pre">twinx()</span></code></a> (more
than two scales are not currently supported, though it is on the wish
list). This works pretty well, though there are some quirks when you
are trying to interactively pan and zoom, because both scales do not get
<aclass="reference internal" href="../api/pyplot_api.html#matplotlib.pyplot.twiny" title="matplotlib.pyplot.twiny"><codeclass="xref py py-func docutils literal"><spanclass="pre">twiny()</span></code></a>) to use <em>2 different axes</em>,
turning the axes rectangular frame off on the 2nd axes to keep it from
obscuring the first, and manually setting the tick locs and labels as
desired. You can use separate <codeclass="docutils literal"><spanclass="pre">matplotlib.ticker</span></code> formatters and
locators as desired because the two axes are independent.</p>
See <aclass="reference internal" href="../examples/api/two_scales.html#api-two-scales"><spanclass="std std-ref">api example code: two_scales.py</span></a> for a complete example</div>
<spanid="howto-batch"></span><h3>Generate images without having a window appear<aclass="headerlink" href="#generate-images-without-having-a-window-appear" title="Permalink to this headline">¶</a></h3>
<p>The easiest way to do this is use a non-interactive backend (see
<aclass="reference internal" href="usage_faq.html#what-is-a-backend"><spanclass="std std-ref">What is a backend?</span></a>) such as Agg (for PNGs), PDF, SVG or PS. In
your figure-generating script, just call the
<aclass="reference internal" href="../api/matplotlib_configuration_api.html#matplotlib.use" title="matplotlib.use"><codeclass="xref py py-func docutils literal"><spanclass="pre">matplotlib.use()</span></code></a> directive before importing pylab or
<pclass="last"><aclass="reference internal" href="#howto-webapp"><spanclass="std std-ref">Matplotlib in a web application server</span></a> for information about running matplotlib inside
of a web application.</p>
</div>
</div>
<divclass="section" id="use-show">
<spanid="howto-show"></span><h3>Use <aclass="reference internal" href="../api/pyplot_api.html#matplotlib.pyplot.show" title="matplotlib.pyplot.show"><codeclass="xref py py-func docutils literal"><spanclass="pre">show()</span></code></a><aclass="headerlink" href="#use-show" title="Permalink to this headline">¶</a></h3>
<p>When you want to view your plots on your display,
the user interface backend will need to start the GUI mainloop.
This is what <aclass="reference internal" href="../api/pyplot_api.html#matplotlib.pyplot.show" title="matplotlib.pyplot.show"><codeclass="xref py py-func docutils literal"><spanclass="pre">show()</span></code></a> does. It tells
Matplotlib to raise all of the figure windows created so far and start
the mainloop. Because this mainloop is blocking by default (i.e., script
execution is paused), you should only call this once per script, at the end.
Script execution is resumed after the last window is closed. Therefore, if
you are using Matplotlib to generate only images and do not want a user
interface window, you do not need to call <codeclass="docutils literal"><spanclass="pre">show</span></code> (see <aclass="reference internal" href="#howto-batch"><spanclass="std std-ref">Generate images without having a window appear</span></a>
and <aclass="reference internal" href="usage_faq.html#what-is-a-backend"><spanclass="std std-ref">What is a backend?</span></a>).</p>
<divclass="admonition note">
<pclass="first admonition-title">Note</p>
<pclass="last">Because closing a figure window invokes the destruction of its plotting
elements, you should call <aclass="reference internal" href="../api/pyplot_api.html#matplotlib.pyplot.savefig" title="matplotlib.pyplot.savefig"><codeclass="xref py py-func docutils literal"><spanclass="pre">savefig()</span></code></a><em>before</em>
calling <codeclass="docutils literal"><spanclass="pre">show</span></code> if you wish to save the figure as well as view it.</p>
</div>
<divclass="versionadded">
<p><spanclass="versionmodified">New in version v1.0.0: </span><codeclass="docutils literal"><spanclass="pre">show</span></code> now starts the GUI mainloop only if it isn’t already running.
Therefore, multiple calls to <codeclass="docutils literal"><spanclass="pre">show</span></code> are now allowed.</p>
</div>
<p>Having <codeclass="docutils literal"><spanclass="pre">show</span></code> block further execution of the script or the python
interpreter depends on whether Matplotlib is set for interactive mode
or not. In non-interactive mode (the default setting), execution is paused
until the last figure window is closed. In interactive mode, the execution
is not paused, which allows you to create additional figures (but the script
won’t finish until the last figure window is closed).</p>
<divclass="admonition note">
<pclass="first admonition-title">Note</p>
<pclass="last">Support for interactive/non-interactive mode depends upon the backend.
Until version 1.0.0 (and subsequent fixes for 1.0.1), the behavior of
the interactive mode was not consistent across backends.
As of v1.0.1, only the macosx backend differs from other backends
because it does not support non-interactive mode.</p>
</div>
<p>Because it is expensive to draw, you typically will not want Matplotlib
to redraw a figure many times in a script such as the following:</p>
<divclass="highlight-default"><divclass="highlight"><pre><span></span><spanclass="n">plot</span><spanclass="p">([</span><spanclass="mi">1</span><spanclass="p">,</span><spanclass="mi">2</span><spanclass="p">,</span><spanclass="mi">3</span><spanclass="p">])</span><spanclass="c1"># draw here ?</span>
<spanclass="n">xlabel</span><spanclass="p">(</span><spanclass="s1">'time'</span><spanclass="p">)</span><spanclass="c1"># and here ?</span>
<spanclass="n">ylabel</span><spanclass="p">(</span><spanclass="s1">'volts'</span><spanclass="p">)</span><spanclass="c1"># and here ?</span>
<spanclass="n">title</span><spanclass="p">(</span><spanclass="s1">'a simple plot'</span><spanclass="p">)</span><spanclass="c1"># and here ?</span>
<p>However, it is <em>possible</em> to force Matplotlib to draw after every command,
which might be what you want when working interactively at the
python console (see <aclass="reference internal" href="../users/shell.html#mpl-shell"><spanclass="std std-ref">Using matplotlib in a python shell</span></a>), but in a script you want to
defer all drawing until the call to <codeclass="docutils literal"><spanclass="pre">show</span></code>. This is especially
important for complex figures that take some time to draw.
<aclass="reference internal" href="../api/pyplot_api.html#matplotlib.pyplot.show" title="matplotlib.pyplot.show"><codeclass="xref py py-func docutils literal"><spanclass="pre">show()</span></code></a> is designed to tell Matplotlib that
you’re all done issuing commands and you want to draw the figure now.</p>
<divclass="admonition note">
<pclass="first admonition-title">Note</p>
<pclass="last"><aclass="reference internal" href="../api/pyplot_api.html#matplotlib.pyplot.show" title="matplotlib.pyplot.show"><codeclass="xref py py-func docutils literal"><spanclass="pre">show()</span></code></a> should typically only be called at
most once per script and it should be the last line of your
script. At that point, the GUI takes control of the interpreter.
<p>This is not what show does and unfortunately, because doing blocking
calls across user interfaces can be tricky, is currently unsupported,
though we have made significant progress towards supporting blocking events.</p>
<divclass="versionadded">
<p><spanclass="versionmodified">New in version v1.0.0: </span>As noted earlier, this restriction has been relaxed to allow multiple
calls to <codeclass="docutils literal"><spanclass="pre">show</span></code>. In <em>most</em> backends, you can now expect to be
able to create new figures and raise them in a subsequent call to
<codeclass="docutils literal"><spanclass="pre">show</span></code> after closing the figures from a previous call to <codeclass="docutils literal"><spanclass="pre">show</span></code>.</p>
<spanid="howto-boxplot-violinplot"></span><h3>Interpreting box plots and violin plots<aclass="headerlink" href="#interpreting-box-plots-and-violin-plots" title="Permalink to this headline">¶</a></h3>
<p>Tukey’s <aclass="reference external" href="http://matplotlib.org/examples/pylab_examples/boxplot_demo.html">box plots</a> (Robert McGill, John W. Tukey and Wayne A. Larsen: “The American Statistician” Vol. 32, No. 1, Feb., 1978, pp. 12-16) are statistical plots that provide useful information about the data distribution such as skewness. However, bar plots with error bars are still the common standard in most scientific literature, and thus, the interpretation of box plots can be challenging for the unfamiliar reader. The figure below illustrates the different visual features of a box plot.</p>
<p><aclass="reference external" href="http://matplotlib.org/examples/statistics/violinplot_demo.html">Violin plots</a> are closely related to box plots but add useful information such as the distribution of the sample data (density trace).
Violin plots were added in Matplotlib 1.4.</p>
</div>
</div>
<divclass="section" id="contributing-howto">
<spanid="howto-contribute"></span><h2>Contributing: howto<aclass="headerlink" href="#contributing-howto" title="Permalink to this headline">¶</a></h2>
<divclass="section" id="request-a-new-feature">
<spanid="how-to-request-feature"></span><h3>Request a new feature<aclass="headerlink" href="#request-a-new-feature" title="Permalink to this headline">¶</a></h3>
<p>Is there a feature you wish Matplotlib had? Then ask! The best
way to get started is to email the developer <aclass="reference external" href="mailto:matplotlib-devel%40python.org">mailing
list</a> for discussion.
This is an open source project developed primarily in the
contributors free time, so there is no guarantee that your
feature will be added. The <em>best</em> way to get the feature
<spanid="how-to-submit-patch"></span><h3>Reporting a bug or submitting a patch<aclass="headerlink" href="#reporting-a-bug-or-submitting-a-patch" title="Permalink to this headline">¶</a></h3>
<p>The development of Matplotlib is organized through <aclass="reference external" href="https://github.com/matplotlib/matplotlib">github</a>. If you would like
to report a bug or submit a patch please use that interface.</p>
<p>To report a bug <aclass="reference external" href="https://github.com/matplotlib/matplotlib/issues/new">create an issue</a> on github
(this requires having a github account). Please include a <aclass="reference external" href="http://sscce.org">Short,
Self Contained, Correct (Compilable), Example</a>
demonstrating what the bug is. Including a clear, easy to test
example makes it easy for the developers to evaluate the bug. Expect
that the bug reports will be a conversation. If you do not want to
register with github, please email bug reports to the <aclass="reference external" href="mailto:matplotlib-devel%40python.org">mailing list</a>.</p>
<p>The easiest way to submit patches to Matplotlib is through pull
requests on github. Please see the <aclass="reference internal" href="../devel/index.html#developers-guide-index"><spanclass="std std-ref">The Matplotlib Developers’ Guide</span></a> for
<spanid="how-to-contribute-docs"></span><h3>Contribute to Matplotlib documentation<aclass="headerlink" href="#contribute-to-matplotlib-documentation" title="Permalink to this headline">¶</a></h3>
<p>Matplotlib is a big library, which is used in many ways, and the
documentation has only scratched the surface of everything it can
do. So far, the place most people have learned all these features are
through studying the examples (<aclass="reference internal" href="#how-to-search-examples"><spanclass="std std-ref">Search examples</span></a>), which is a
recommended and great way to learn, but it would be nice to have more
official narrative documentation guiding people through all the dark
corners. This is where you come in.</p>
<p>There is a good chance you know more about Matplotlib usage in some
areas, the stuff you do every day, than many of the core developers
who wrote most of the documentation. Just pulled your hair out
compiling Matplotlib for windows? Write a FAQ or a section for the
<aclass="reference internal" href="installing_faq.html#installing-faq"><spanclass="std std-ref">Installation</span></a> page. Are you a digital signal processing wizard?
Write a tutorial on the signal analysis plotting functions like
<aclass="reference internal" href="../api/pyplot_api.html#matplotlib.pyplot.specgram" title="matplotlib.pyplot.specgram"><codeclass="xref py py-func docutils literal"><spanclass="pre">specgram()</span></code></a>. Do you use Matplotlib with
<aclass="reference external" href="https://www.djangoproject.com/">django</a> or other popular web
application servers? Write a FAQ or tutorial and we’ll find a place
for it in the <aclass="reference internal" href="../users/index.html#users-guide-index"><spanclass="std std-ref">User’s Guide</span></a>. Bundle Matplotlib in a
<aclass="reference external" href="http://www.py2exe.org/">py2exe</a> app? ... I think you get the idea.</p>
<p>Matplotlib is documented using the <aclass="reference external" href="http://www.sphinx-doc.org/index.html">sphinx</a> extensions to restructured text
<aclass="reference external" href="http://docutils.sourceforge.net/rst.html">(ReST)</a>. sphinx is an
extensible python framework for documentation projects which generates
HTML and PDF, and is pretty easy to write; you can see the source for this
document or any page on this site by clicking on the <em>Show Source</em> link
at the end of the page in the sidebar.</p>
<p>The sphinx website is a good resource for learning sphinx, but we have
put together a cheat-sheet at <aclass="reference internal" href="../devel/documenting_mpl.html#documenting-matplotlib"><spanclass="std std-ref">Developer’s tips for documenting matplotlib</span></a> which
shows you how to get started, and outlines the Matplotlib conventions
and extensions, e.g., for including plots directly from external code in
your documents.</p>
<p>Once your documentation contributions are working (and hopefully
tested by actually <em>building</em> the docs) you can submit them as a patch
against git. See <aclass="reference internal" href="../devel/gitwash/git_install.html#install-git"><spanclass="std std-ref">Install git</span></a> and <aclass="reference internal" href="#how-to-submit-patch"><spanclass="std std-ref">Reporting a bug or submitting a patch</span></a>.
Looking for something to do? Search for <aclass="reference external" href="../search.html?q=todo">TODO</a>
<spanid="howto-webapp"></span><h2>Matplotlib in a web application server<aclass="headerlink" href="#matplotlib-in-a-web-application-server" title="Permalink to this headline">¶</a></h2>
<p>Many users report initial problems trying to use maptlotlib in web
application servers, because by default Matplotlib ships configured to
work with a graphical user interface which may require an X11
connection. Since many barebones application servers do not have X11
enabled, you may get errors if you don’t configure Matplotlib for use
in these environments. Most importantly, you need to decide what
kinds of images you want to generate (PNG, PDF, SVG) and configure the
appropriate default backend. For 99% of users, this will be the Agg
<spanclass="n">imgdata</span><spanclass="o">.</span><spanclass="n">seek</span><spanclass="p">(</span><spanclass="mi">0</span><spanclass="p">)</span><spanclass="c1"># rewind the data</span>
<h3>Matplotlib with apache<aclass="headerlink" href="#matplotlib-with-apache" title="Permalink to this headline">¶</a></h3>
<p>TODO; see <aclass="reference internal" href="#how-to-contribute-docs"><spanclass="std std-ref">Contribute to Matplotlib documentation</span></a>.</p>
</div>
<divclass="section" id="matplotlib-with-django">
<h3>Matplotlib with django<aclass="headerlink" href="#matplotlib-with-django" title="Permalink to this headline">¶</a></h3>
<p>TODO; see <aclass="reference internal" href="#how-to-contribute-docs"><spanclass="std std-ref">Contribute to Matplotlib documentation</span></a>.</p>
</div>
<divclass="section" id="matplotlib-with-zope">
<h3>Matplotlib with zope<aclass="headerlink" href="#matplotlib-with-zope" title="Permalink to this headline">¶</a></h3>
<p>TODO; see <aclass="reference internal" href="#how-to-contribute-docs"><spanclass="std std-ref">Contribute to Matplotlib documentation</span></a>.</p>
<spanid="howto-click-maps"></span><h3>Clickable images for HTML<aclass="headerlink" href="#clickable-images-for-html" title="Permalink to this headline">¶</a></h3>
<p>Andrew Dalke of <aclass="reference external" href="http://www.dalkescientific.com">Dalke Scientific</a>
has written a nice <aclass="reference external" href="http://www.dalkescientific.com/writings/diary/archive/2005/04/24/interactive_html.html">article</a>
on how to make html click maps with Matplotlib agg PNGs. We would
also like to add this functionality to SVG. If you are interested in
contributing to these efforts that would be great.</p>
</div>
</div>
<divclass="section" id="search-examples">
<spanid="how-to-search-examples"></span><h2>Search examples<aclass="headerlink" href="#search-examples" title="Permalink to this headline">¶</a></h2>
<p>The nearly 300 code <aclass="reference internal" href="../examples/index.html#examples-index"><spanclass="std std-ref">Matplotlib Examples</span></a> included with the Matplotlib
source distribution are full-text searchable from the <aclass="reference internal" href="../search.html"><spanclass="std std-ref">Search Page</span></a>
page, but sometimes when you search, you get a lot of results from the
<aclass="reference internal" href="../api/index.html#api-index"><spanclass="std std-ref">The Matplotlib API</span></a> or other documentation that you may not be interested
in if you just want to find a complete, free-standing, working piece
of example code. To facilitate example searches, we have tagged every
code example page with the keyword <codeclass="docutils literal"><spanclass="pre">codex</span></code> for <em>code example</em> which
shouldn’t appear anywhere else on this site except in the FAQ.
So if you want to search for an example that uses an
ellipse, <aclass="reference internal" href="../search.html"><spanclass="std std-ref">Search Page</span></a> for <codeclass="docutils literal"><spanclass="pre">codex</span><spanclass="pre">ellipse</span></code>.</p>
</div>
<divclass="section" id="cite-matplotlib">
<spanid="how-to-cite-mpl"></span><h2>Cite Matplotlib<aclass="headerlink" href="#cite-matplotlib" title="Permalink to this headline">¶</a></h2>
<p>If you want to refer to Matplotlib in a publication, you can use
“Matplotlib: A 2D Graphics Environment” by J. D. Hunter In Computing
in Science & Engineering, Vol. 9, No. 3. (2007), pp. 90-95 (see <aclass="reference external" href="https://doi.org/10.1109/MCSE.2007.55">this