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
Copy file name to clipboardExpand all lines: doc/users/artists.rst
+30-3Lines changed: 30 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -19,8 +19,24 @@ the ``Artist`` handles all the high level constructs like representing
19
19
and laying out the figure, text, and lines. The typical user will
20
20
spend 95% of his time working with the ``Artists``.
21
21
22
-
There are two types of ``Artists``: primitives and containers. The primitives represent the standard graphical objects we want to paint onto our canvas: :class:`~matplotlib.lines.Line2D`, :class:`~matplotlib.patches.Rectangle`, :class:`~matplotlib.text.Text`, :class:`~matplotlib.image.AxesImage`, etc., and the containers are places to put them (:class:`~matplotlib.axis.Axis`, :class:`~matplotlib.axes.Axes` and :class:`~matplotlib.figure.Figure`). The standard use is to create a :class:`~matplotlib.figure.Figure` instance, use the ``Figure`` to create one or more :class:`~matplotlib.axes.Axes` or :class:`~matplotlib.axes.Subplot` instances, and use the ``Axes`` instance helper methods to create the primitives. In the example below, we create a ``Figure`` instance using :func:`matplotlib.pyplot.figure`, which is a convenience method for instantiating ``Figure`` instances and connecting them with your user interface or drawing toolkit ``FigureCanvas``. As we will discuss below, this is not necessary -- you
23
-
can work directly with PostScript, PDF Gtk+, or wxPython ``FigureCanvas`` instances, instantiate your ``Figures`` directly and connect them yourselves -- but since we are focusing here on the ``Artist`` API we'll let :mod:`~matplotlib.pyplot` handle some of those details for us::
22
+
There are two types of ``Artists``: primitives and containers. The primitives
23
+
represent the standard graphical objects we want to paint onto our canvas:
:class:`~matplotlib.text.Text`, :class:`~matplotlib.image.AxesImage`, etc., and
26
+
the containers are places to put them (:class:`~matplotlib.axis.Axis`,
27
+
:class:`~matplotlib.axes.Axes` and :class:`~matplotlib.figure.Figure`). The
28
+
standard use is to create a :class:`~matplotlib.figure.Figure` instance, use
29
+
the ``Figure`` to create one or more :class:`~matplotlib.axes.Axes` or
30
+
:class:`~matplotlib.axes.Subplot` instances, and use the ``Axes`` instance
31
+
helper methods to create the primitives. In the example below, we create a
32
+
``Figure`` instance using :func:`matplotlib.pyplot.figure`, which is a
33
+
convenience method for instantiating ``Figure`` instances and connecting them
34
+
with your user interface or drawing toolkit ``FigureCanvas``. As we will
35
+
discuss below, this is not necessary -- you can work directly with PostScript,
36
+
PDF Gtk+, or wxPython ``FigureCanvas`` instances, instantiate your ``Figures``
37
+
directly and connect them yourselves -- but since we are focusing here on the
38
+
``Artist`` API we'll let :mod:`~matplotlib.pyplot` handle some of those details
39
+
for us::
24
40
25
41
import matplotlib.pyplot as plt
26
42
fig = plt.figure()
@@ -517,7 +533,18 @@ and zooming, as well as the :class:`~matplotlib.ticker.Locator` and
517
533
:class:`~matplotlib.ticker.Formatter` instances which control where
518
534
the ticks are placed and how they are represented as strings.
519
535
520
-
Each ``Axis`` object contains a :attr:`~matplotlib.axis.Axis.label` attribute (this is what :mod:`~matplotlib.pylab` modifies in calls to :func:`~matplotlib.pylab.xlabel` and :func:`~matplotlib.pylab.ylabel`) as well as a list of major and minor ticks. The ticks are :class:`~matplotlib.axis.XTick` and :class:`~matplotlib.axis.YTick` instances, which contain the actual line and text primitives that render the ticks and ticklabels. Because the ticks are dynamically created as needed (e.g., when panning and zooming), you should access the lists of major and minor ticks through their accessor methods :meth:`~matplotlib.axis.Axis.get_major_ticks` and :meth:`~matplotlib.axis.Axis.get_minor_ticks`. Although the ticks contain all the primitives and will be covered below, the ``Axis`` methods contain accessor methods to return the tick lines, tick labels, tick locations etc.:
536
+
Each ``Axis`` object contains a :attr:`~matplotlib.axis.Axis.label` attribute
537
+
(this is what :mod:`~matplotlib.pylab` modifies in calls to
538
+
:func:`~matplotlib.pylab.xlabel` and :func:`~matplotlib.pylab.ylabel`) as well
539
+
as a list of major and minor ticks. The ticks are
540
+
:class:`~matplotlib.axis.XTick` and :class:`~matplotlib.axis.YTick` instances,
541
+
which contain the actual line and text primitives that render the ticks and
542
+
ticklabels. Because the ticks are dynamically created as needed (e.g., when
543
+
panning and zooming), you should access the lists of major and minor ticks
544
+
through their accessor methods :meth:`~matplotlib.axis.Axis.get_major_ticks`
545
+
and :meth:`~matplotlib.axis.Axis.get_minor_ticks`. Although the ticks contain
546
+
all the primitives and will be covered below, the ``Axis`` methods contain
547
+
accessor methods to return the tick lines, tick labels, tick locations etc.:
0 commit comments