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
<spanid="artists-tutorial"></span><spanid="sphx-glr-tutorials-artists-py"></span><h1>Artist tutorial<aclass="headerlink" href="#artist-tutorial" title="Link to this heading">#</a></h1>
<p>Using Artist objects to render on the canvas.</p>
<p>There are three layers to the Matplotlib API.</p>
<ulclass="simple">
<li><p>the <codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">matplotlib.backend_bases.FigureCanvas</span></code> is the area onto which
the figure is drawn</p></li>
<li><p>the <codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">matplotlib.backend_bases.Renderer</span></code> is the object which knows how
to draw on the <codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">FigureCanvas</span></code></p></li>
<li><p>and the <aclass="reference internal" href="../api/artist_api.html#matplotlib.artist.Artist" title="matplotlib.artist.Artist"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">matplotlib.artist.Artist</span></code></a> is the object that knows how to use
a renderer to paint onto the canvas.</p></li>
</ul>
<p>The <codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">FigureCanvas</span></code> and
<codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">Renderer</span></code> handle all the details of
talking to user interface toolkits like <aclass="reference external" href="https://www.wxpython.org">wxPython</a> or drawing languages like PostScript®, and
the <codeclass="docutils literal notranslate"><spanclass="pre">Artist</span></code> handles all the high level constructs like representing
and laying out the figure, text, and lines. The typical user will
spend 95% of their time working with the <codeclass="docutils literal notranslate"><spanclass="pre">Artists</span></code>.</p>
<p>There are two types of <codeclass="docutils literal notranslate"><spanclass="pre">Artists</span></code>: primitives and containers. The primitives
represent the standard graphical objects we want to paint onto our canvas:
the containers are places to put them (<aclass="reference internal" href="../api/axis_api.html#matplotlib.axis.Axis" title="matplotlib.axis.Axis"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">Axis</span></code></a>,
<aclass="reference internal" href="../api/_as_gen/matplotlib.axes.Axes.html#matplotlib.axes.Axes" title="matplotlib.axes.Axes"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">Axes</span></code></a> and <aclass="reference internal" href="../api/_as_gen/matplotlib.figure.Figure.html#matplotlib.figure.Figure" title="matplotlib.figure.Figure"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">Figure</span></code></a>). The
standard use is to create a <aclass="reference internal" href="../api/_as_gen/matplotlib.figure.Figure.html#matplotlib.figure.Figure" title="matplotlib.figure.Figure"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">Figure</span></code></a> instance, use
the <codeclass="docutils literal notranslate"><spanclass="pre">Figure</span></code> to create one or more <aclass="reference internal" href="../api/_as_gen/matplotlib.axes.Axes.html#matplotlib.axes.Axes" title="matplotlib.axes.Axes"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">Axes</span></code></a>
instances, and use the <codeclass="docutils literal notranslate"><spanclass="pre">Axes</span></code> instance
helper methods to create the primitives. In the example below, we create a
<codeclass="docutils literal notranslate"><spanclass="pre">Figure</span></code> instance using <aclass="reference internal" href="../api/_as_gen/matplotlib.pyplot.figure.html#matplotlib.pyplot.figure" title="matplotlib.pyplot.figure"><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">matplotlib.pyplot.figure()</span></code></a>, which is a
convenience method for instantiating <codeclass="docutils literal notranslate"><spanclass="pre">Figure</span></code> instances and connecting them
with your user interface or drawing toolkit <codeclass="docutils literal notranslate"><spanclass="pre">FigureCanvas</span></code>. As we will
discuss below, this is not necessary -- you can work directly with PostScript,
PDF Gtk+, or wxPython <codeclass="docutils literal notranslate"><spanclass="pre">FigureCanvas</span></code> instances, instantiate your <codeclass="docutils literal notranslate"><spanclass="pre">Figures</span></code>
directly and connect them yourselves -- but since we are focusing here on the
<codeclass="docutils literal notranslate"><spanclass="pre">Artist</span></code> API we'll let <aclass="reference internal" href="../api/pyplot_summary.html#module-matplotlib.pyplot" title="matplotlib.pyplot"><codeclass="xref py py-mod docutils literal notranslate"><spanclass="pre">pyplot</span></code></a> handle some of those details
<ahref="../api/_as_gen/matplotlib.axes.Axes.html#matplotlib.axes.Axes" title="matplotlib.axes.Axes" class="sphx-glr-backref-module-matplotlib-axes sphx-glr-backref-type-py-class sphx-glr-backref-instance"><spanclass="n">ax</span></a><spanclass="o">=</span><ahref="../api/_as_gen/matplotlib.figure.Figure.add_subplot.html#matplotlib.figure.Figure.add_subplot" title="matplotlib.figure.Figure.add_subplot" class="sphx-glr-backref-module-matplotlib-figure sphx-glr-backref-type-py-method"><spanclass="n">fig</span><spanclass="o">.</span><spanclass="n">add_subplot</span></a><spanclass="p">(</span><spanclass="mi">2</span><spanclass="p">,</span><spanclass="mi">1</span><spanclass="p">,</span><spanclass="mi">1</span><spanclass="p">)</span><spanclass="c1"># two rows, one column, first plot</span>
</pre></div>
</div>
<p>The <aclass="reference internal" href="../api/_as_gen/matplotlib.axes.Axes.html#matplotlib.axes.Axes" title="matplotlib.axes.Axes"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">Axes</span></code></a> is probably the most important
class in the Matplotlib API, and the one you will be working with most
of the time. This is because the <codeclass="docutils literal notranslate"><spanclass="pre">Axes</span></code> is the plotting area into
which most of the objects go, and the <codeclass="docutils literal notranslate"><spanclass="pre">Axes</span></code> has many special helper
<aclass="reference internal" href="../api/_as_gen/matplotlib.axes.Axes.imshow.html#matplotlib.axes.Axes.imshow" title="matplotlib.axes.Axes.imshow"><codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">imshow()</span></code></a>) to create the most common
will take your data (e.g., <codeclass="docutils literal notranslate"><spanclass="pre">numpy</span></code> arrays and strings) and create
primitive <codeclass="docutils literal notranslate"><spanclass="pre">Artist</span></code> instances as needed (e.g., <codeclass="docutils literal notranslate"><spanclass="pre">Line2D</span></code>), add them to
the relevant containers, and draw them when requested. If you want to create
an <codeclass="docutils literal notranslate"><spanclass="pre">Axes</span></code> at an arbitrary location, simply use the
<aclass="reference internal" href="../api/_as_gen/matplotlib.figure.Figure.add_axes.html#matplotlib.figure.Figure.add_axes" title="matplotlib.figure.Figure.add_axes"><codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">add_axes()</span></code></a> method which takes a list
of <codeclass="docutils literal notranslate"><spanclass="pre">[left,</span><spanclass="pre">bottom,</span><spanclass="pre">width,</span><spanclass="pre">height]</span></code> values in 0-1 relative figure
<p>In this example, <codeclass="docutils literal notranslate"><spanclass="pre">ax</span></code> is the <codeclass="docutils literal notranslate"><spanclass="pre">Axes</span></code> instance created by the
<codeclass="docutils literal notranslate"><spanclass="pre">fig.add_subplot</span></code> call above and when you call <codeclass="docutils literal notranslate"><spanclass="pre">ax.plot</span></code>, it creates a
<codeclass="docutils literal notranslate"><spanclass="pre">Line2D</span></code> instance and
adds it to the <codeclass="docutils literal notranslate"><spanclass="pre">Axes</span></code>. In the interactive <aclass="reference external" href="https://ipython.org/">IPython</a>
session below, you can see that the <codeclass="docutils literal notranslate"><spanclass="pre">Axes.lines</span></code> list is length one and
contains the same line that was returned by the <codeclass="docutils literal notranslate"><spanclass="pre">line,</span><spanclass="pre">=</span><spanclass="pre">ax.plot...</span></code> call:</p>
<spanclass="gh">Out[102]: </span><spanclass="go"><matplotlib.lines.Line2D at 0x19a95710></span>
</pre></div>
</div>
<p>If you make subsequent calls to <codeclass="docutils literal notranslate"><spanclass="pre">ax.plot</span></code> (and the hold state is "on"
which is the default) then additional lines will be added to the list.
You can remove a line later by calling its <codeclass="docutils literal notranslate"><spanclass="pre">remove</span></code> method:</p>
it passes the information on the <aclass="reference internal" href="../api/text_api.html#matplotlib.text.Text" title="matplotlib.text.Text"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">Text</span></code></a>
instance of the <aclass="reference internal" href="../api/axis_api.html#matplotlib.axis.XAxis" title="matplotlib.axis.XAxis"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">XAxis</span></code></a>. Each <codeclass="docutils literal notranslate"><spanclass="pre">Axes</span></code>
instance contains an <aclass="reference internal" href="../api/axis_api.html#matplotlib.axis.XAxis" title="matplotlib.axis.XAxis"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">XAxis</span></code></a> and a
<aclass="reference internal" href="../api/axis_api.html#matplotlib.axis.YAxis" title="matplotlib.axis.YAxis"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">YAxis</span></code></a> instance, which handle the layout and
drawing of the ticks, tick labels and axis labels.</p>
<imgsrc="../_images/sphx_glr_artists_001.png" srcset="../_images/sphx_glr_artists_001.png, ../_images/sphx_glr_artists_001_2_00x.png 2.00x" alt="A sine wave" class = "sphx-glr-single-img"/><sectionid="customizing-your-objects">
<spanid="customizing-artists"></span><h2>Customizing your objects<aclass="headerlink" href="#customizing-your-objects" title="Link to this heading">#</a></h2>
<p>Every element in the figure is represented by a Matplotlib
<aclass="reference internal" href="../api/artist_api.html#matplotlib.artist.Artist" title="matplotlib.artist.Artist"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">Artist</span></code></a>, and each has an extensive list of
properties to configure its appearance. The figure itself contains a
<aclass="reference internal" href="../api/_as_gen/matplotlib.patches.Rectangle.html#matplotlib.patches.Rectangle" title="matplotlib.patches.Rectangle"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">Rectangle</span></code></a> exactly the size of the figure,
which you can use to set the background color and transparency of the
(the standard white box with black edges in the typical Matplotlib
plot, has a <codeclass="docutils literal notranslate"><spanclass="pre">Rectangle</span></code> instance that determines the color,
transparency, and other properties of the Axes. These instances are
stored as member variables <codeclass="xref py py-attr docutils literal notranslate"><spanclass="pre">Figure.patch</span></code> and <codeclass="xref py py-attr docutils literal notranslate"><spanclass="pre">Axes.patch</span></code> ("Patch" is a name inherited from
MATLAB, and is a 2D "patch" of color on the figure, e.g., rectangles,
circles and polygons). Every Matplotlib <codeclass="docutils literal notranslate"><spanclass="pre">Artist</span></code> has the following
<aclass="reference internal" href="../api/_as_gen/matplotlib.pyplot.getp.html#matplotlib.pyplot.getp" title="matplotlib.pyplot.getp"><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">getp()</span></code></a> in pyplot), which lists the properties
and their values. This works for classes derived from <codeclass="docutils literal notranslate"><spanclass="pre">Artist</span></code> as
well, e.g., <codeclass="docutils literal notranslate"><spanclass="pre">Figure</span></code> and <codeclass="docutils literal notranslate"><spanclass="pre">Rectangle</span></code>. Here are the <codeclass="docutils literal notranslate"><spanclass="pre">Figure</span></code> rectangle
<p>The docstrings for all of the classes also contain the <codeclass="docutils literal notranslate"><spanclass="pre">Artist</span></code>
properties, so you can consult the interactive "help" or the
<aclass="reference internal" href="../api/artist_api.html#artist-api"><spanclass="std std-ref">matplotlib.artist</span></a> for a listing of properties for a given object.</p>
</section>
<sectionid="object-containers">
<spanid="id1"></span><h2>Object containers<aclass="headerlink" href="#object-containers" title="Link to this heading">#</a></h2>
<p>Now that we know how to inspect and set the properties of a given
object we want to configure, we need to know how to get at that object.
As mentioned in the introduction, there are two kinds of objects:
primitives and containers. The primitives are usually the things you
want to configure (the font of a <aclass="reference internal" href="../api/text_api.html#matplotlib.text.Text" title="matplotlib.text.Text"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">Text</span></code></a>
instance, the width of a <aclass="reference internal" href="../api/_as_gen/matplotlib.lines.Line2D.html#matplotlib.lines.Line2D" title="matplotlib.lines.Line2D"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">Line2D</span></code></a>) although
the containers also have some properties as well -- for example the
<aclass="reference internal" href="../api/_as_gen/matplotlib.axes.Axes.html#matplotlib.axes.Axes" title="matplotlib.axes.Axes"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">Axes</span></code></a><aclass="reference internal" href="../api/artist_api.html#matplotlib.artist.Artist" title="matplotlib.artist.Artist"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">Artist</span></code></a> is a
container that contains many of the primitives in your plot, but it
also has properties like the <codeclass="docutils literal notranslate"><spanclass="pre">xscale</span></code> to control whether the xaxis
is 'linear' or 'log'. In this section we'll review where the various
container objects store the <codeclass="docutils literal notranslate"><spanclass="pre">Artists</span></code> that you want to get at.</p>
<sectionid="figure-container">
<spanid="id2"></span><h3>Figure container<aclass="headerlink" href="#figure-container" title="Link to this heading">#</a></h3>
<p>The top level container <codeclass="docutils literal notranslate"><spanclass="pre">Artist</span></code> is the
<aclass="reference internal" href="../api/_as_gen/matplotlib.figure.Figure.html#matplotlib.figure.Figure" title="matplotlib.figure.Figure"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">matplotlib.figure.Figure</span></code></a>, and it contains everything in the
figure. The background of the figure is a
<aclass="reference internal" href="../api/_as_gen/matplotlib.patches.Rectangle.html#matplotlib.patches.Rectangle" title="matplotlib.patches.Rectangle"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">Rectangle</span></code></a> which is stored in
<codeclass="xref py py-attr docutils literal notranslate"><spanclass="pre">Figure.patch</span></code>. As
you add subplots (<aclass="reference internal" href="../api/_as_gen/matplotlib.figure.Figure.add_subplot.html#matplotlib.figure.Figure.add_subplot" title="matplotlib.figure.Figure.add_subplot"><codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">add_subplot()</span></code></a>) and
Axes (<aclass="reference internal" href="../api/_as_gen/matplotlib.figure.Figure.add_axes.html#matplotlib.figure.Figure.add_axes" title="matplotlib.figure.Figure.add_axes"><codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">add_axes()</span></code></a>) to the figure
these will be appended to the <aclass="reference internal" href="../api/_as_gen/matplotlib.figure.Figure.axes.html#matplotlib.figure.Figure.axes" title="matplotlib.figure.Figure.axes"><codeclass="xref py py-attr docutils literal notranslate"><spanclass="pre">Figure.axes</span></code></a>. These are also returned by the
<spanclass="go">[<Axes:>, <matplotlib.axes._axes.Axes object at 0x7f0768702be0>]</span>
</pre></div>
</div>
<p>Because the figure maintains the concept of the "current Axes" (see
<aclass="reference internal" href="../api/_as_gen/matplotlib.figure.Figure.gca.html#matplotlib.figure.Figure.gca" title="matplotlib.figure.Figure.gca"><codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">Figure.gca</span></code></a> and
<aclass="reference internal" href="../api/_as_gen/matplotlib.figure.Figure.sca.html#matplotlib.figure.Figure.sca" title="matplotlib.figure.Figure.sca"><codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">Figure.sca</span></code></a>) to support the
pylab/pyplot state machine, you should not insert or remove Axes
directly from the Axes list, but rather use the
<aclass="reference internal" href="../api/_as_gen/matplotlib.figure.Figure.add_subplot.html#matplotlib.figure.Figure.add_subplot" title="matplotlib.figure.Figure.add_subplot"><codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">add_subplot()</span></code></a> and
<aclass="reference internal" href="../api/_as_gen/matplotlib.figure.Figure.add_axes.html#matplotlib.figure.Figure.add_axes" title="matplotlib.figure.Figure.add_axes"><codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">add_axes()</span></code></a> methods to insert, and the
<aclass="reference internal" href="../api/_as_gen/matplotlib.artist.Artist.remove.html#matplotlib.artist.Artist.remove" title="matplotlib.artist.Artist.remove"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Axes.remove</span></code></a> method to delete. You are
free however, to iterate over the list of Axes or index into it to get
access to <codeclass="docutils literal notranslate"><spanclass="pre">Axes</span></code> instances you want to customize. Here is an
<p>The figure also has its own <codeclass="docutils literal notranslate"><spanclass="pre">images</span></code>, <codeclass="docutils literal notranslate"><spanclass="pre">lines</span></code>, <codeclass="docutils literal notranslate"><spanclass="pre">patches</span></code> and <codeclass="docutils literal notranslate"><spanclass="pre">text</span></code>
attributes, which you can use to add primitives directly. When doing so, the
default coordinate system for the <codeclass="docutils literal notranslate"><spanclass="pre">Figure</span></code> will simply be in pixels (which
is not usually what you want). If you instead use Figure-level methods to add
Artists (e.g., using <aclass="reference internal" href="../api/_as_gen/matplotlib.figure.Figure.text.html#matplotlib.figure.Figure.text" title="matplotlib.figure.Figure.text"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Figure.text</span></code></a> to add text), then the default coordinate
system will be "figure coordinates" where (0, 0) is the bottom-left of the
figure and (1, 1) is the top-right of the figure.</p>
<p>As with all <codeclass="docutils literal notranslate"><spanclass="pre">Artist</span></code>s, you can control this coordinate system by setting
the transform property. You can explicitly use "figure coordinates" by
setting the <codeclass="docutils literal notranslate"><spanclass="pre">Artist</span></code> transform to <codeclass="xref py py-attr docutils literal notranslate"><spanclass="pre">fig.transFigure</span></code>:</p>
<imgsrc="../_images/sphx_glr_artists_002.png" srcset="../_images/sphx_glr_artists_002.png, ../_images/sphx_glr_artists_002_2_00x.png 2.00x" alt="artists" class = "sphx-glr-single-img"/><p>Here is a summary of the Artists the Figure contains</p>
<spanid="id3"></span><h3>Axes container<aclass="headerlink" href="#axes-container" title="Link to this heading">#</a></h3>
<p>The <aclass="reference internal" href="../api/_as_gen/matplotlib.axes.Axes.html#matplotlib.axes.Axes" title="matplotlib.axes.Axes"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">matplotlib.axes.Axes</span></code></a> is the center of the Matplotlib
universe -- it contains the vast majority of all the <codeclass="docutils literal notranslate"><spanclass="pre">Artists</span></code> used
in a figure with many helper methods to create and add these
<codeclass="docutils literal notranslate"><spanclass="pre">Artists</span></code> to itself, as well as helper methods to access and
customize the <codeclass="docutils literal notranslate"><spanclass="pre">Artists</span></code> it contains. Like the
<aclass="reference internal" href="../api/_as_gen/matplotlib.figure.Figure.html#matplotlib.figure.Figure" title="matplotlib.figure.Figure"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">Figure</span></code></a>, it contains a
<codeclass="xref py py-attr docutils literal notranslate"><spanclass="pre">patch</span></code> which is a
<aclass="reference internal" href="../api/_as_gen/matplotlib.patches.Rectangle.html#matplotlib.patches.Rectangle" title="matplotlib.patches.Rectangle"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">Rectangle</span></code></a> for Cartesian coordinates and a
<aclass="reference internal" href="../api/_as_gen/matplotlib.patches.Circle.html#matplotlib.patches.Circle" title="matplotlib.patches.Circle"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">Circle</span></code></a> for polar coordinates; this patch
determines the shape, background and border of the plotting region:</p>
<p>When you call a plotting method, e.g., the canonical
<aclass="reference internal" href="../api/_as_gen/matplotlib.axes.Axes.plot.html#matplotlib.axes.Axes.plot" title="matplotlib.axes.Axes.plot"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">plot</span></code></a> and pass in arrays or lists of values, the
method will create a <aclass="reference internal" href="../api/_as_gen/matplotlib.lines.Line2D.html#matplotlib.lines.Line2D" title="matplotlib.lines.Line2D"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">matplotlib.lines.Line2D</span></code></a> instance, update the line with
all the <codeclass="docutils literal notranslate"><spanclass="pre">Line2D</span></code> properties passed as keyword arguments, add the line to
the <codeclass="docutils literal notranslate"><spanclass="pre">Axes</span></code>, and return it to you:</p>
<spanclass="go">[<matplotlib.lines.Line2D at 0xd378b0c>]</span>
</pre></div>
</div>
<p>Similarly, methods that create patches, like
<aclass="reference internal" href="../api/_as_gen/matplotlib.axes.Axes.bar.html#matplotlib.axes.Axes.bar" title="matplotlib.axes.Axes.bar"><codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">bar()</span></code></a> creates a list of rectangles, will
add the patches to the <codeclass="xref py py-attr docutils literal notranslate"><spanclass="pre">Axes.patches</span></code> list:</p>
<p>You should not add objects directly to the <codeclass="docutils literal notranslate"><spanclass="pre">Axes.lines</span></code> or <codeclass="docutils literal notranslate"><spanclass="pre">Axes.patches</span></code>
lists, because the <codeclass="docutils literal notranslate"><spanclass="pre">Axes</span></code> needs to do a few things when it creates and adds
an object:</p>
<ulclass="simple">
<li><p>It sets the <codeclass="docutils literal notranslate"><spanclass="pre">figure</span></code> and <codeclass="docutils literal notranslate"><spanclass="pre">axes</span></code> property of the <codeclass="docutils literal notranslate"><spanclass="pre">Artist</span></code>;</p></li>
<li><p>It sets the default <codeclass="docutils literal notranslate"><spanclass="pre">Axes</span></code> transformation (unless one is already set);</p></li>
<li><p>It inspects the data contained in the <codeclass="docutils literal notranslate"><spanclass="pre">Artist</span></code> to update the data
structures controlling auto-scaling, so that the view limits can be
adjusted to contain the plotted data.</p></li>
</ul>
<p>You can, nonetheless, create objects yourself and add them directly to the
<codeclass="docutils literal notranslate"><spanclass="pre">Axes</span></code> using helper methods like <aclass="reference internal" href="../api/_as_gen/matplotlib.axes.Axes.add_line.html#matplotlib.axes.Axes.add_line" title="matplotlib.axes.Axes.add_line"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">add_line</span></code></a> and
<aclass="reference internal" href="../api/_as_gen/matplotlib.axes.Axes.add_patch.html#matplotlib.axes.Axes.add_patch" title="matplotlib.axes.Axes.add_patch"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">add_patch</span></code></a>. Here is an annotated interactive session