Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c0659d4

Browse files
committed
DOC: Add plot types section to quickstart
Also creates a Patches under the Artists explanations.
1 parent b758c88 commit c0659d4

File tree

3 files changed

+51
-22
lines changed

3 files changed

+51
-22
lines changed

galleries/users_explain/artists/index.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ Note that when we add an Artist manually like this, it doesn't necessarily
176176
adjust the axis limits like most of the helper methods do, so the Artists can
177177
be clipped, as is the case above for the ``clipped_circle`` patch.
178178

179-
See :ref:`artist_reference` for other patches.
179+
See :ref:`artist_reference` or :ref:`patches_artists` for more information on
180+
patches.
180181

181182
Removing Artists
182183
~~~~~~~~~~~~~~~~
@@ -198,3 +199,4 @@ More details
198199
Concept: Path effects guide <patheffects_guide>
199200
In Depth: understanding the extent keyword argument of imshow <imshow_extent>
200201
transforms_tutorial
202+
patches
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""
2+
.. _patches_artists:
3+
4+
=======
5+
Patches
6+
=======
7+
8+
:mod:`Patches <matplotlib.patches>` are a family of Artists that can be used
9+
when drawing arbitrary two-dimensional regions. In addition to the general
10+
Patch Artists :class:`~.patches.PathPatch` and :class:`~.patches.Polygon`,
11+
common shapes have corresponding Patch Artists such as
12+
:class:`~.patches.Circle`, :class:`~.patches.Rectangle`,
13+
:class:`~.patches.Ellipse`, etc.
14+
"""
15+
16+
import matplotlib.pyplot as plt
17+
import matplotlib as mpl
18+
import numpy as np
19+
20+
fig, ax = plt.subplots()
21+
22+
polygon = mpl.patches.Polygon(np.array([[1, 0], [0.5, 1.5], [2, 1]]), closed=True)
23+
ax.add_patch(polygon)
24+
25+
circle = mpl.patches.Circle((2, 2), 0.5, facecolor='orange', edgecolor='black')
26+
ax.add_patch(circle)
27+
28+
ax.set(xlim=(0, 3), ylim=(0, 3), box_aspect=1)

galleries/users_explain/quick_start.py

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,26 @@
111111
# Artists are drawn to the **canvas**. Most Artists are tied to an Axes; such
112112
# an Artist cannot be shared by multiple Axes, or moved from one to another.
113113
#
114+
# .. _plot_types_quickstart:
115+
#
116+
# Plot types
117+
# ==========
118+
#
119+
# For an overview of the different types of plot you can create with Matplotlib,
120+
# see the :ref:`Plot types gallery <plot_types>`. If you don't find the plot
121+
# type you need, it may still be possible to create the visualization you want
122+
# by combining existing Artists and plot elements.
123+
#
124+
# * To manipulate and customize points, see :class:`~.markers.MarkerStyle`
125+
# * To manipulate and customize lines, see :class:`~.lines.Line2D` or
126+
# :class:`~.collections.LineCollection`
127+
# * To manipulate and customize regions, see :mod:`matplotlib.patches`
128+
# * To manipulate and customize :mod:`images <matplotlib.image>`, see
129+
# :class:`~.image.AxesImage`
130+
# * To manipulate and customize contours and (vector) fields, see
131+
# `~.axes.Axes.contour` and `~.axes.Axes.quiver`, respectively.
132+
# * For anything else, see :ref:`artists_tutorial`.
133+
#
114134
# .. _input_types:
115135
#
116136
# Types of inputs to plotting functions
@@ -559,27 +579,6 @@ def my_plotter(ax, data1, data2, param_dict):
559579
# and formatters appropriate to the norm. These can be changed as for
560580
# other Axis objects.
561581

562-
# %%
563-
# Patches
564-
# =======
565-
#
566-
# :mod:`Patches <matplotlib.patches>` are a family of Artists that can be used
567-
# when drawing arbitrary two-dimensional regions. In addition to the general
568-
# Patch Artists :class:`~.patches.PathPatch` and :class:`~.patches.Polygon`,
569-
# common shapes have corresponding Patch Artists such as
570-
# :class:`~.patches.Circle`, :class:`~.patches.Rectangle`,
571-
# :class:`~.patches.Ellipse`, etc.
572-
573-
fig, ax = plt.subplots()
574-
575-
polygon = mpl.patches.Polygon(np.array([[1, 0], [0.5, 1.5], [2, 1]]), closed=True)
576-
ax.add_patch(polygon)
577-
578-
circle = mpl.patches.Circle((2, 2), 0.5, facecolor='orange', edgecolor='black')
579-
ax.add_patch(circle)
580-
581-
ax.set(xlim=(0, 3), ylim=(0, 3), box_aspect=1)
582-
583582
# %%
584583
# Working with multiple Figures and Axes
585584
# ======================================

0 commit comments

Comments
 (0)