@@ -79,13 +79,11 @@ class in the Matplotlib API, and the one you will be working with most
79
79
line, = ax.plot(t, s, color='blue', lw=2)
80
80
81
81
In this example, ``ax`` is the ``Axes`` instance created by the
82
- ``fig.add_subplot`` call above (remember ``Subplot`` is just a
83
- subclass of ``Axes``) and when you call ``ax.plot``, it creates a
84
- ``Line2D`` instance and adds it to the :attr:`Axes.lines
85
- <matplotlib.axes.Axes.lines>` list. In the interactive `IPython
86
- <https://ipython.org/>`_ session below, you can see that the
87
- ``Axes.lines`` list is length one and contains the same line that was
88
- returned by the ``line, = ax.plot...`` call:
82
+ ``fig.add_subplot`` call above (remember ``Subplot`` is just a subclass of
83
+ ``Axes``) and when you call ``ax.plot``, it creates a ``Line2D`` instance and
84
+ adds it to the ``Axes``. In the interactive `IPython <https://ipython.org/>`_
85
+ session below, you can see that the ``Axes.lines`` list is length one and
86
+ contains the same line that was returned by the ``line, = ax.plot...`` call:
89
87
90
88
.. sourcecode:: ipython
91
89
@@ -97,11 +95,10 @@ class in the Matplotlib API, and the one you will be working with most
97
95
98
96
If you make subsequent calls to ``ax.plot`` (and the hold state is "on"
99
97
which is the default) then additional lines will be added to the list.
100
- You can remove lines later simply by calling the list methods; either
101
- of these will work::
98
+ You can remove a line later by calling its ``remove`` method::
102
99
103
- del ax.lines[0]
104
- ax.lines. remove(line) # one or the other, not both!
100
+ line = ax.lines[0]
101
+ line. remove()
105
102
106
103
The Axes also has helper methods to configure and decorate the x-axis
107
104
and y-axis tick, tick labels and axis labels::
@@ -386,11 +383,10 @@ class in the Matplotlib API, and the one you will be working with most
386
383
# rect.set_facecolor('green')
387
384
#
388
385
# When you call a plotting method, e.g., the canonical
389
- # :meth:`~matplotlib.axes.Axes.plot` and pass in arrays or lists of
390
- # values, the method will create a :meth:`matplotlib.lines.Line2D`
391
- # instance, update the line with all the ``Line2D`` properties passed as
392
- # keyword arguments, add the line to the :attr:`Axes.lines
393
- # <matplotlib.axes.Axes.lines>` container, and returns it to you:
386
+ # `~matplotlib.axes.Axes.plot` and pass in arrays or lists of values, the
387
+ # method will create a `matplotlib.lines.Line2D` instance, update the line with
388
+ # all the ``Line2D`` properties passed as keyword arguments, add the line to
389
+ # the ``Axes``, and return it to you:
394
390
#
395
391
# .. sourcecode:: ipython
396
392
#
@@ -423,19 +419,20 @@ class in the Matplotlib API, and the one you will be working with most
423
419
# In [235]: print(len(ax.patches))
424
420
# Out[235]: 50
425
421
#
426
- # You should not add objects directly to the ``Axes.lines`` or
427
- # ``Axes.patches`` lists unless you know exactly what you are doing,
428
- # because the ``Axes`` needs to do a few things when it creates and adds
429
- # an object. It sets the figure and axes property of the ``Artist``, as
430
- # well as the default ``Axes`` transformation (unless a transformation
431
- # is set). It also inspects the data contained in the ``Artist`` to
432
- # update the data structures controlling auto-scaling, so that the view
433
- # limits can be adjusted to contain the plotted data. You can,
434
- # nonetheless, create objects yourself and add them directly to the
435
- # ``Axes`` using helper methods like
436
- # :meth:`~matplotlib.axes.Axes.add_line` and
437
- # :meth:`~matplotlib.axes.Axes.add_patch`. Here is an annotated
438
- # interactive session illustrating what is going on:
422
+ # You should not add objects directly to the ``Axes.lines`` or ``Axes.patches``
423
+ # lists, because the ``Axes`` needs to do a few things when it creates and adds
424
+ # an object:
425
+ #
426
+ # - It sets the ``figure`` and ``axes`` property of the ``Artist``;
427
+ # - It sets the default ``Axes`` transformation (unless one is already set);
428
+ # - It inspects the data contained in the ``Artist`` to update the data
429
+ # structures controlling auto-scaling, so that the view limits can be
430
+ # adjusted to contain the plotted data.
431
+ #
432
+ # You can, nonetheless, create objects yourself and add them directly to the
433
+ # ``Axes`` using helper methods like `~matplotlib.axes.Axes.add_line` and
434
+ # `~matplotlib.axes.Axes.add_patch`. Here is an annotated interactive session
435
+ # illustrating what is going on:
439
436
#
440
437
# .. sourcecode:: ipython
441
438
#
0 commit comments