Skip to content

Commit

Permalink
Backport PR matplotlib#27268: Copy-edit various examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
anntzer authored and meeseeksmachine committed Nov 5, 2023
1 parent c59f152 commit f32d0f1
Show file tree
Hide file tree
Showing 14 changed files with 42 additions and 61 deletions.
3 changes: 1 addition & 2 deletions galleries/examples/color/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
Color
=====

For more in-depth information about the colormaps available in matplotlib
as well as a description of their properties,
For a description of the colormaps available in Matplotlib,
see the :ref:`colormaps tutorial <tutorials-colors>`.
2 changes: 1 addition & 1 deletion galleries/examples/color/named_colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
List of named colors
====================
This plots a list of the named colors supported in matplotlib.
This plots a list of the named colors supported by Matplotlib.
For more information on colors in matplotlib see
* the :ref:`colors_def` tutorial;
Expand Down
8 changes: 3 additions & 5 deletions galleries/examples/images_contours_and_fields/image_demo.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
"""
==========
Image demo
==========
Many ways to plot images in Matplotlib.
========================
Many ways to plot images
========================
The most common way to plot images in Matplotlib is with
`~.axes.Axes.imshow`. The following examples demonstrate much of the
Expand Down
12 changes: 5 additions & 7 deletions galleries/examples/images_contours_and_fields/pcolor_demo.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
"""
===========
Pcolor demo
===========
=============
pcolor images
=============
Generating images with `~.axes.Axes.pcolor`.
Pcolor allows you to generate 2D image-style plots. Below we will show how
to do so in Matplotlib.
`~.Axes.pcolor` generates 2D image-style plots, as illustrated below.
"""

import matplotlib.pyplot as plt
import numpy as np

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
r"""
=================================
Using accented text in Matplotlib
=================================
=============
Accented text
=============
Matplotlib supports accented characters via TeX mathtext or Unicode.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Annotating Plots
================
The following examples show how it is possible to annotate plots in Matplotlib.
The following examples show ways to annotate plots in Matplotlib.
This includes highlighting specific points of interest and using various
visual tools to call attention to this point. For a more complete and in-depth
description of the annotation and text tools in Matplotlib, see the
Expand Down
6 changes: 3 additions & 3 deletions galleries/examples/text_labels_and_annotations/font_file.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
r"""
===================================
Using a ttf font file in Matplotlib
===================================
====================
Using ttf font files
====================
Although it is usually not a good idea to explicitly point to a single ttf file
for a font instance, you can do so by passing a `pathlib.Path` instance as the
Expand Down
2 changes: 0 additions & 2 deletions galleries/examples/text_labels_and_annotations/legend_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
Legend Demo
===========
Plotting legends in Matplotlib.
There are many ways to create and customize legends in Matplotlib. Below
we'll show a few examples for how to do so.
Expand Down
8 changes: 3 additions & 5 deletions galleries/users_explain/axes/constrainedlayout_guide.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,13 @@
.. warning::
Calling ``plt.tight_layout()`` will turn off *constrained layout*!
Calling `~.pyplot.tight_layout` will turn off *constrained layout*!
Simple example
==============
In Matplotlib, the location of Axes (including subplots) are specified in
normalized figure coordinates. It can happen that your axis labels or titles
(or sometimes even ticklabels) go outside the figure area, and are thus
clipped.
With the default Axes positioning, the axes title, axis labels, or tick labels
can sometimes go outside the figure area, and thus get clipped.
"""

# sphinx_gallery_thumbnail_number = 18
Expand Down
11 changes: 4 additions & 7 deletions galleries/users_explain/axes/legend_guide.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@
Legend guide
============
Generating legends flexibly in Matplotlib.
.. currentmodule:: matplotlib.pyplot
This legend guide is an extension of the documentation available at
:func:`~matplotlib.pyplot.legend` - please ensure you are familiar with
contents of that documentation before proceeding with this guide.
This legend guide extends the `~.Axes.legend` docstring -
please read it before proceeding with this guide.
This guide makes use of some common terms, which are documented here for
clarity:
Expand Down Expand Up @@ -62,8 +59,8 @@
line_down, = ax.plot([3, 2, 1], label='Line 1')
ax.legend(handles=[line_up, line_down])
In some cases, it is not possible to set the label of the handle, so it is
possible to pass through the list of labels to :func:`legend`::
In the rare case where the labels cannot directly be set on the handles, they
can also be directly passed to :func:`legend`::
fig, ax = plt.subplots()
line_up, = ax.plot([1, 2, 3], label='Line 2')
Expand Down
16 changes: 6 additions & 10 deletions galleries/users_explain/axes/tight_layout_guide.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,11 @@
An alternative to *tight_layout* is :ref:`constrained_layout
<constrainedlayout_guide>`.
Simple Example
Simple example
==============
In matplotlib, the location of axes (including subplots) are specified in
normalized figure coordinates. It can happen that your axis labels or
titles (or sometimes even ticklabels) go outside the figure area, and are thus
clipped.
With the default Axes positioning, the axes title, axis labels, or tick labels
can sometimes go outside the figure area, and thus get clipped.
"""

# sphinx_gallery_thumbnail_number = 7
Expand Down Expand Up @@ -190,8 +186,8 @@ def example_plot(ax, fontsize=12):

# %%
# You may provide an optional *rect* parameter, which specifies the bounding
# box that the subplots will be fit inside. The coordinates must be in
# normalized figure coordinates and the default is (0, 0, 1, 1).
# box that the subplots will be fit inside. The coordinates are in
# normalized figure coordinates and default to (0, 0, 1, 1) (the whole figure).

fig = plt.figure()

Expand Down Expand Up @@ -245,7 +241,7 @@ def example_plot(ax, fontsize=12):
# Use with AxesGrid1
# ==================
#
# While limited, :mod:`mpl_toolkits.axes_grid1` is also supported.
# Limited support for :mod:`mpl_toolkits.axes_grid1` is provided.

from mpl_toolkits.axes_grid1 import Grid

Expand Down
15 changes: 6 additions & 9 deletions galleries/users_explain/colors/colormap-manipulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,25 @@
.. _colormap-manipulation:
********************************
Creating Colormaps in Matplotlib
********************************
******************
Creating Colormaps
******************
Matplotlib has a number of built-in colormaps accessible via
`.matplotlib.colormaps`. There are also external libraries like
palettable_ that have many extra colormaps.
.. _palettable: https://jiffyclub.github.io/palettable/
However, we often want to create or manipulate colormaps in Matplotlib.
However, we may also want to create or manipulate our own colormaps.
This can be done using the class `.ListedColormap` or
`.LinearSegmentedColormap`.
Seen from the outside, both colormap classes map values between 0 and 1 to
a bunch of colors. There are, however, slight differences, some of which are
shown in the following.
Both colormap classes map values between 0 and 1 to colors. There are however
differences, as explained below.
Before manually creating or manipulating colormaps, let us first see how we
can obtain colormaps and their colors from existing colormap classes.
Getting colormaps and accessing their values
============================================
Expand All @@ -32,7 +30,6 @@
which returns a colormap object. The length of the list of colors used
internally to define the colormap can be adjusted via `.Colormap.resampled`.
Below we use a modest value of 8 so there are not a lot of values to look at.
"""

import matplotlib.pyplot as plt
Expand Down
6 changes: 3 additions & 3 deletions galleries/users_explain/colors/colormaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
.. _colormaps:
********************************
Choosing Colormaps in Matplotlib
********************************
******************
Choosing Colormaps
******************
Matplotlib has a number of built-in colormaps accessible via
`.matplotlib.colormaps`. There are also external libraries that
Expand Down
6 changes: 3 additions & 3 deletions galleries/users_explain/text/text_intro.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
.. _text_intro:
========================
Text in Matplotlib Plots
========================
==================
Text in Matplotlib
==================
Introduction to plotting and working with text in Matplotlib.
Expand Down

0 comments on commit f32d0f1

Please sign in to comment.