diff --git a/.flake8 b/.flake8 index ee739cdf4231..c11645341933 100644 --- a/.flake8 +++ b/.flake8 @@ -60,6 +60,7 @@ per-file-ignores = galleries/users_explain/artists/transforms_tutorial.py: E402, E501 galleries/users_explain/colors/colormaps.py: E501 galleries/users_explain/colors/colors.py: E402 + galleries/users_explain/quick_start.py: E402 galleries/tutorials/artists.py: E402 galleries/users_explain/axes/constrainedlayout_guide.py: E402 galleries/users_explain/axes/legend_guide.py: E402 diff --git a/galleries/users_explain/artists/index.rst b/galleries/users_explain/artists/index.rst index d3f2918c9a91..66cab003da63 100644 --- a/galleries/users_explain/artists/index.rst +++ b/galleries/users_explain/artists/index.rst @@ -21,3 +21,4 @@ and :doc:`Axes <../axes/index>` are Artists, and generally contain Path effects guide Understanding the extent keyword argument of imshow transforms_tutorial + patches diff --git a/galleries/users_explain/artists/patches.py b/galleries/users_explain/artists/patches.py new file mode 100644 index 000000000000..50fcf1fb1b96 --- /dev/null +++ b/galleries/users_explain/artists/patches.py @@ -0,0 +1,28 @@ +""" +.. _patches_artists: + +======= +Patches +======= + +:mod:`Patches ` are a family of Artists that can be used +when drawing arbitrary two-dimensional regions. In addition to the general +Patch Artists :class:`~.patches.PathPatch` and :class:`~.patches.Polygon`, +common shapes have corresponding Patch Artists such as +:class:`~.patches.Circle`, :class:`~.patches.Rectangle`, +:class:`~.patches.Ellipse`, etc. +""" + +import matplotlib.pyplot as plt +import matplotlib as mpl +import numpy as np + +fig, ax = plt.subplots() + +polygon = mpl.patches.Polygon(np.array([[1, 0], [0.5, 1.5], [2, 1]]), closed=True) +ax.add_patch(polygon) + +circle = mpl.patches.Circle((2, 2), 0.5, facecolor='orange', edgecolor='black') +ax.add_patch(circle) + +ax.set(xlim=(0, 3), ylim=(0, 3), box_aspect=1) diff --git a/galleries/users_explain/quick_start.py b/galleries/users_explain/quick_start.py index cf2d5850e6e5..8f6f6c1e5f6c 100644 --- a/galleries/users_explain/quick_start.py +++ b/galleries/users_explain/quick_start.py @@ -111,6 +111,45 @@ # Artists are drawn to the **canvas**. Most Artists are tied to an Axes; such # an Artist cannot be shared by multiple Axes, or moved from one to another. # +# .. _plot_types_quickstart: +# +# Plot types +# ========== +# +# For an overview of the different types of plots you can create with Matplotlib, +# see the :ref:`Plot types gallery `. If you don't find the plot +# type you need, it may still be possible to create the visualization you want +# For example, Matplotlib does not provide a method to automatically annotate a +# distribution plot. Instead, you can create this visualization by combining the +# `~.matplotlib.axes.Axes.plot` method to draw the distribution, the +# `~.matplotlib.axes.Axes.axhline` method to draw the mean, and +# `~matplotlib.axes.Axes.axhspan` to shade the standard deviation region. + +x = np.array([3, 4, 9, 8, 9, 8, 0, 8, 4, 8]) +fig, ax = plt.subplots() + +# Compute the mean and standard deviation of the data +mean = np.mean(x) +std = np.std(x) + +# Add a horizontal line for the mean, and a rectangle representing the +# standard deviation of the data +ln_data = ax.plot(x, label='Data') +ln_mean = ax.axhline(mean, color='red', label='Mean') +ln_std = ax.axhspan(mean-std, mean+std, alpha=0.1, label=r'$\sigma$') + +ax.legend() + +# Now, you can use object methods to directly customize your plot. +# Note that ln_data is a list of `~.matplotlib.lines.Line2D` objects - we'll +# modify the first entry in this list. +ln_data[0].set_color('orange') +ln_mean.set_linestyle(':') +ln_std.set_hatch('oo') +# %% +# For more information on creating artists from their constructors, see +# :ref:`artists_tutorial`. +# # .. _input_types: # # Types of inputs to plotting functions @@ -206,8 +245,8 @@ # You may find older examples that use the ``pylab`` interface, # via ``from pylab import *``. This approach is strongly deprecated. # -# Making a helper functions -# ------------------------- +# Making helper functions +# ----------------------- # # If you need to make the same plots over and over again with different data # sets, or want to easily wrap Matplotlib methods, use the recommended @@ -558,8 +597,8 @@ def my_plotter(ax, data1, data2, param_dict): # control the size. Finally, the colorbar will have default locators # and formatters appropriate to the norm. These can be changed as for # other Axis objects. -# -# + +# %% # Working with multiple Figures and Axes # ====================================== # @@ -588,3 +627,6 @@ def my_plotter(ax, data1, data2, param_dict): # For more plot types see :doc:`Plot types ` and the # :doc:`API reference `, in particular the # :doc:`Axes API `. +# +# For more information on coordinate systems and transformations, see the +# :ref:`transforms_tutorial`. pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy