Skip to content

Consistently use 3D, 2D, 1D for dimensionality #18706

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions examples/images_contours_and_fields/image_transparency_blend.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
"""
===========================================
Blend transparency with color in 2-D images
===========================================
==========================================
Blend transparency with color in 2D images
==========================================

Blend transparency with color to highlight parts of data with imshow.

A common use for `matplotlib.pyplot.imshow` is to plot a 2-D statistical
map. The function makes it easy to visualize a 2-D matrix as an image and add
A common use for `matplotlib.pyplot.imshow` is to plot a 2D statistical
map. The function makes it easy to visualize a 2D matrix as an image and add
transparency to the output. For example, one can plot a statistic (such as a
t-statistic) and color the transparency of each pixel according to its p-value.
This example demonstrates how you can achieve this effect.

First we will generate some data, in this case, we'll create two 2-D "blobs"
in a 2-D grid. One blob will be positive, and the other negative.
First we will generate some data, in this case, we'll create two 2D "blobs"
in a 2D grid. One blob will be positive, and the other negative.
"""

# sphinx_gallery_thumbnail_number = 3
Expand Down
2 changes: 1 addition & 1 deletion examples/images_contours_and_fields/pcolor_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

Generating images with `~.axes.Axes.pcolor`.

Pcolor allows you to generate 2-D image-style plots. Below we will show how
Pcolor allows you to generate 2D image-style plots. Below we will show how
to do so in Matplotlib.
"""
import matplotlib.pyplot as plt
Expand Down
2 changes: 1 addition & 1 deletion examples/images_contours_and_fields/pcolormesh_levels.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pcolormesh
==========

`.axes.Axes.pcolormesh` allows you to generate 2-D image-style plots. Note it
`.axes.Axes.pcolormesh` allows you to generate 2D image-style plots. Note it
is faster than the similar `~.axes.Axes.pcolor`.

"""
Expand Down
2 changes: 1 addition & 1 deletion examples/mplot3d/quiver3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
3D quiver plot
==============

Demonstrates plotting directional arrows at points on a 3d meshgrid.
Demonstrates plotting directional arrows at points on a 3D meshgrid.
"""

import matplotlib.pyplot as plt
Expand Down
2 changes: 1 addition & 1 deletion examples/statistics/hexbin_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Plotting hexbins with Matplotlib.

Hexbin is an axes method or pyplot function that is essentially
a pcolor of a 2-D histogram with hexagonal cells. It can be
a pcolor of a 2D histogram with hexagonal cells. It can be
much more informative than a scatter plot. In the first plot
below, try substituting 'scatter' for 'hexbin'.
"""
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/_cm.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def cubehelix(gamma=1.0, s=0.5, r=-1.5, h=1.0):
can be visualised as a squashed helix around the diagonal in the
(r, g, b) color cube.

For a unit color cube (i.e. 3-D coordinates for (r, g, b) each in the
For a unit color cube (i.e. 3D coordinates for (r, g, b) each in the
range 0 to 1) the color scheme starts at (r, g, b) = (0, 0, 0), i.e. black,
and finishes at (r, g, b) = (1, 1, 1), i.e. white. For some fraction *x*,
between 0 and 1, the color is the corresponding grey value at that
Expand Down
26 changes: 13 additions & 13 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2028,11 +2028,11 @@ def step(self, x, y, *args, where='pre', data=None, **kwargs):
Parameters
----------
x : array-like
1-D sequence of x positions. It is assumed, but not checked, that
1D sequence of x positions. It is assumed, but not checked, that
it is uniformly increasing.

y : array-like
1-D sequence of y levels.
1D sequence of y levels.

fmt : str, optional
A format string, e.g. 'g' for a green line. See `.plot` for a more
Expand Down Expand Up @@ -4200,7 +4200,7 @@ def invalid_shape_exception(csize, xsize):
"RGBA sequence, which should be avoided as value-"
"mapping will have precedence in case its length "
"matches with *x* & *y*. Please use the *color* "
"keyword-argument or provide a 2-D array "
"keyword-argument or provide a 2D array "
"with a single row if you intend to specify "
"the same RGB or RGBA value for all points.")
valid_shape = False
Expand Down Expand Up @@ -4253,14 +4253,14 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,

- A scalar or sequence of n numbers to be mapped to colors using
*cmap* and *norm*.
- A 2-D array in which the rows are RGB or RGBA.
- A 2D array in which the rows are RGB or RGBA.
- A sequence of colors of length n.
- A single color format string.

Note that *c* should not be a single numeric RGB or RGBA sequence
because that is indistinguishable from an array of values to be
colormapped. If you want to specify the same RGB or RGBA value for
all points, use a 2-D array with a single row. Otherwise, value-
all points, use a 2D array with a single row. Otherwise, value-
matching will have precedence in case of a size matching with *x*
and *y*.

Expand Down Expand Up @@ -4341,7 +4341,7 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
case all masks will be combined and only unmasked points will be
plotted.

* Fundamentally, scatter works with 1-D arrays; *x*, *y*, *s*, and *c*
* Fundamentally, scatter works with 1D arrays; *x*, *y*, *s*, and *c*
may be input as N-D arrays, but within scatter they will be
flattened. The exception is *c*, which will be flattened only if its
size matches the size of *x* and *y*.
Expand Down Expand Up @@ -5597,7 +5597,7 @@ def pcolor(self, *args, shading=None, alpha=None, norm=None, cmap=None,
Parameters
----------
C : array-like
A scalar 2-D array. The values will be color-mapped.
A scalar 2D array. The values will be color-mapped.

X, Y : array-like, optional
The coordinates of the corners of quadrilaterals of a pcolormesh::
Expand All @@ -5623,7 +5623,7 @@ def pcolor(self, *args, shading=None, alpha=None, norm=None, cmap=None,
color ``C[i, j]`` will be centered on ``(X[i, j], Y[i, j])``.

If *X* and/or *Y* are 1-D arrays or column vectors they will be
expanded as needed into the appropriate 2-D arrays, making a
expanded as needed into the appropriate 2D arrays, making a
rectangular grid.

shading : {'flat', 'nearest', 'auto'}, optional
Expand Down Expand Up @@ -5841,7 +5841,7 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
Parameters
----------
C : array-like
A scalar 2-D array. The values will be color-mapped.
A scalar 2D array. The values will be color-mapped.

X, Y : array-like, optional
The coordinates of the corners of quadrilaterals of a pcolormesh::
Expand Down Expand Up @@ -5869,7 +5869,7 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
interpolation is caried out between the quadrilateral corners.

If *X* and/or *Y* are 1-D arrays or column vectors they will be
expanded as needed into the appropriate 2-D arrays, making a
expanded as needed into the appropriate 2D arrays, making a
rectangular grid.

cmap : str or `~matplotlib.colors.Colormap`, default: :rc:`image.cmap`
Expand Down Expand Up @@ -5970,7 +5970,7 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None,

**Differences between pcolor() and pcolormesh()**

Both methods are used to create a pseudocolor plot of a 2-D array
Both methods are used to create a pseudocolor plot of a 2D array
using quadrilaterals.

The main difference lies in the created object and internal data
Expand Down Expand Up @@ -6300,7 +6300,7 @@ def hist(self, x, bins=None, range=None, density=False, weights=None,

Multiple data can be provided via *x* as a list of datasets
of potentially different length ([*x0*, *x1*, ...]), or as
a 2-D ndarray in which each column is a dataset. Note that
a 2D ndarray in which each column is a dataset. Note that
the ndarray form is transposed relative to the list form.

Masked arrays are not supported.
Expand Down Expand Up @@ -7478,7 +7478,7 @@ def specgram(self, x, NFFT=None, Fs=None, Fc=None, detrend=None,

Returns
-------
spectrum : 2-D array
spectrum : 2D array
Columns are the periodograms of successive segments.

freqs : 1-D array
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/axes/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ def _plot_args(self, tup, kwargs, return_kwargs=False):
raise ValueError(f"x and y must have same first dimension, but "
f"have shapes {x.shape} and {y.shape}")
if x.ndim > 2 or y.ndim > 2:
raise ValueError(f"x and y can be no greater than 2-D, but have "
raise ValueError(f"x and y can be no greater than 2D, but have "
f"shapes {x.shape} and {y.shape}")
if x.ndim == 1:
x = x[:, np.newaxis]
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/cbook/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1300,7 +1300,7 @@ def _to_unmasked_float_array(x):


def _check_1d(x):
"""Convert scalars to 1d arrays; pass-through arrays as is."""
"""Convert scalars to 1D arrays; pass-through arrays as is."""
if not hasattr(x, 'shape') or len(x.shape) < 1:
return np.atleast_1d(x)
else:
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/cm.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def to_rgba(self, x, alpha=None, bytes=False, norm=True):
"""
Return a normalized rgba array corresponding to *x*.

In the normal case, *x* is a 1-D or 2-D sequence of scalars, and
In the normal case, *x* is a 1D or 2D sequence of scalars, and
the corresponding ndarray of rgba values will be returned,
based on the norm and colormap set for this ScalarMappable.

Expand Down
10 changes: 5 additions & 5 deletions lib/matplotlib/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ class ColorConverter:

def _create_lookup_table(N, data, gamma=1.0):
r"""
Create an *N* -element 1-d lookup table.
Create an *N* -element 1D lookup table.

This assumes a mapping :math:`f : [0, 1] \rightarrow [0, 1]`. The returned
data is an array of N values :math:`y = f(x)` where x is sampled from
Expand Down Expand Up @@ -1795,7 +1795,7 @@ def hillshade(self, elevation, vert_exag=1, dx=1, dy=1, fraction=1.):
Parameters
----------
elevation : array-like
A 2d array (or equivalent) of the height values used to generate an
A 2D array (or equivalent) of the height values used to generate an
illumination map
vert_exag : number, optional
The amount to exaggerate the elevation values by when calculating
Expand All @@ -1817,7 +1817,7 @@ def hillshade(self, elevation, vert_exag=1, dx=1, dy=1, fraction=1.):
Returns
-------
ndarray
A 2d array of illumination values between 0-1, where 0 is
A 2D array of illumination values between 0-1, where 0 is
completely in shadow and 1 is completely illuminated.
"""

Expand Down Expand Up @@ -1860,7 +1860,7 @@ def shade_normals(self, normals, fraction=1.):
Returns
-------
ndarray
A 2d array of illumination values between 0-1, where 0 is
A 2D array of illumination values between 0-1, where 0 is
completely in shadow and 1 is completely illuminated.
"""

Expand Down Expand Up @@ -1893,7 +1893,7 @@ def shade(self, data, cmap, norm=None, blend_mode='overlay', vmin=None,
Parameters
----------
data : array-like
A 2d array (or equivalent) of the height values used to generate a
A 2D array (or equivalent) of the height values used to generate a
shaded map.
cmap : `~matplotlib.colors.Colormap`
The colormap used to color the *data* array. Note that this must be
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/contour.py
Original file line number Diff line number Diff line change
Expand Up @@ -1564,7 +1564,7 @@ def _initialize_x_y(self, z):
X, Y : array-like, optional
The coordinates of the values in *Z*.

*X* and *Y* must both be 2-D with the same shape as *Z* (e.g.
*X* and *Y* must both be 2D with the same shape as *Z* (e.g.
created via `numpy.meshgrid`), or they must both be 1-D such
that ``len(X) == M`` is the number of columns in *Z* and
``len(Y) == N`` is the number of rows in *Z*.
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -3229,7 +3229,7 @@ def figaspect(arg):

Parameters
----------
arg : float or 2d array
arg : float or 2D array
If a float, this defines the aspect ratio (i.e. the ratio height /
width).
In case of an array the aspect ratio is number of rows / number of
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def composite_images(images, renderer, magnification=1.0):

Returns
-------
image : uint8 3d array
image : uint8 array (M, N, 4)
The composited RGBA image.
offset_x, offset_y : float
The (left, bottom) offset where the composited image should be placed
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/mlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ def specgram(x, NFFT=None, Fs=None, detrend=None, window=None,
Returns
-------
spectrum : array-like
2-D array, columns are the periodograms of successive segments.
2D array, columns are the periodograms of successive segments.

freqs : array-like
1-D array, frequencies corresponding to the rows in *spectrum*.
Expand Down Expand Up @@ -841,7 +841,7 @@ class GaussianKDE:
----------
dataset : array-like
Datapoints to estimate from. In case of univariate data this is a 1-D
array, otherwise a 2-D array with shape (# of dims, # of data).
array, otherwise a 2D array with shape (# of dims, # of data).

bw_method : str, scalar or callable, optional
The method used to calculate the estimator bandwidth. This can be
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def vertices(self, vertices):
@property
def codes(self):
"""
The list of codes in the `Path` as a 1-D numpy array. Each
The list of codes in the `Path` as a 1D numpy array. Each
code is one of `STOP`, `MOVETO`, `LINETO`, `CURVE3`, `CURVE4`
or `CLOSEPOLY`. For codes that correspond to more than one
vertex (`CURVE3` and `CURVE4`), that code will be repeated so
Expand Down
12 changes: 6 additions & 6 deletions lib/matplotlib/stackplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ def stackplot(axes, x, *args,

Parameters
----------
x : 1d array of dimension N
x : array-like (N)

y : 2d array (dimension MxN), or sequence of 1d arrays (each dimension 1xN)
y : 2D array (M, N) or sequence of array-like (N)

The data is assumed to be unstacked. Each of the following
calls is legal::

stackplot(x, y) # where y is MxN
stackplot(x, y1, y2, y3, y4) # where y1, y2, y3, y4, are all 1xNm
stackplot(x, y) # where y has shape (M, N)
stackplot(x, y1, y2, y3) # where y1, y2, y3, y4 have length N

baseline : {'zero', 'sym', 'wiggle', 'weighted_wiggle'}
Method used to calculate the baseline:
Expand All @@ -42,10 +42,10 @@ def stackplot(axes, x, *args,
size of each layer. It is also called 'Streamgraph'-layout. More
details can be found at http://leebyron.com/streamgraph/.

labels : Length N sequence of strings
labels : Length N list of str
Labels to assign to each data series.

colors : Length N sequence of colors
colors : Length N list of color
A list or tuple of colors. These will be cycled through and used to
colour the stacked areas.

Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1213,7 +1213,7 @@ class Transform(TransformNode):

The following attributes may be overridden if the default is unsuitable:

- :attr:`is_separable` (defaults to True for 1d -> 1d transforms, False
- :attr:`is_separable` (defaults to True for 1D -> 1D transforms, False
otherwise)
- :attr:`has_inverse` (defaults to True if :meth:`inverted` is overridden,
False otherwise)
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/tri/triangulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __init__(self, x, y, triangles=None, mask=None):
self.x = np.asarray(x, dtype=np.float64)
self.y = np.asarray(y, dtype=np.float64)
if self.x.shape != self.y.shape or self.x.ndim != 1:
raise ValueError("x and y must be equal-length 1-D arrays")
raise ValueError("x and y must be equal-length 1D arrays")

self.mask = None
self._edges = None
Expand Down
6 changes: 3 additions & 3 deletions lib/matplotlib/tri/triinterpolate.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,9 @@ def _interpolate_single_key(self, return_key, tri_index, x, y):
----------
return_index : {'z', 'dzdx', 'dzdy'}
Identifies the requested values (z or its derivatives)
tri_index : 1d int array
tri_index : 1D int array
Valid triangle index (-1 prohibited)
x, y : 1d arrays, same shape as `tri_index`
x, y : 1D arrays, same shape as `tri_index`
Valid locations where interpolation is requested.

Returns
Expand Down Expand Up @@ -290,7 +290,7 @@ class CubicTriInterpolator(TriInterpolator):

In one-dimension - on a segment - a cubic interpolating function is
defined by the values of the function and its derivative at both ends.
This is almost the same in 2-d inside a triangle, except that the values
This is almost the same in 2D inside a triangle, except that the values
of the function and its 2 derivatives have to be defined at each triangle
node.

Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/tri/trirefine.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def refine_field(self, z, triinterpolator=None, subdiv=3):

Parameters
----------
z : 1d-array-like of length ``n_points``
z : array-like of length ``n_points``
Values of the field to refine, defined at the nodes of the
encapsulated triangulation. (``n_points`` is the number of points
in the initial triangulation)
Expand All @@ -151,7 +151,7 @@ def refine_field(self, z, triinterpolator=None, subdiv=3):
-------
refi_tri : `~matplotlib.tri.Triangulation`
The returned refined triangulation.
refi_z : 1d array of length: *refi_tri* node count.
refi_z : 1D array of length: *refi_tri* node count.
The returned interpolated field (at *refi_tri* nodes).
"""
if triinterpolator is None:
Expand Down
Loading