Skip to content

Commit 06567e0

Browse files
authored
Merge pull request #18706 from timhoffm/2D
Consistently use 3D, 2D, 1D for dimensionality
2 parents 7ee15a6 + 00a4dab commit 06567e0

26 files changed

+64
-64
lines changed

examples/images_contours_and_fields/image_transparency_blend.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
"""
2-
===========================================
3-
Blend transparency with color in 2-D images
4-
===========================================
2+
==========================================
3+
Blend transparency with color in 2D images
4+
==========================================
55
66
Blend transparency with color to highlight parts of data with imshow.
77
8-
A common use for `matplotlib.pyplot.imshow` is to plot a 2-D statistical
9-
map. The function makes it easy to visualize a 2-D matrix as an image and add
8+
A common use for `matplotlib.pyplot.imshow` is to plot a 2D statistical
9+
map. The function makes it easy to visualize a 2D matrix as an image and add
1010
transparency to the output. For example, one can plot a statistic (such as a
1111
t-statistic) and color the transparency of each pixel according to its p-value.
1212
This example demonstrates how you can achieve this effect.
1313
14-
First we will generate some data, in this case, we'll create two 2-D "blobs"
15-
in a 2-D grid. One blob will be positive, and the other negative.
14+
First we will generate some data, in this case, we'll create two 2D "blobs"
15+
in a 2D grid. One blob will be positive, and the other negative.
1616
"""
1717

1818
# sphinx_gallery_thumbnail_number = 3

examples/images_contours_and_fields/pcolor_demo.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
Generating images with `~.axes.Axes.pcolor`.
77
8-
Pcolor allows you to generate 2-D image-style plots. Below we will show how
8+
Pcolor allows you to generate 2D image-style plots. Below we will show how
99
to do so in Matplotlib.
1010
"""
1111
import matplotlib.pyplot as plt

examples/images_contours_and_fields/pcolormesh_levels.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
pcolormesh
44
==========
55
6-
`.axes.Axes.pcolormesh` allows you to generate 2-D image-style plots. Note it
6+
`.axes.Axes.pcolormesh` allows you to generate 2D image-style plots. Note it
77
is faster than the similar `~.axes.Axes.pcolor`.
88
99
"""

examples/mplot3d/quiver3d.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
3D quiver plot
44
==============
55
6-
Demonstrates plotting directional arrows at points on a 3d meshgrid.
6+
Demonstrates plotting directional arrows at points on a 3D meshgrid.
77
"""
88

99
import matplotlib.pyplot as plt

examples/statistics/hexbin_demo.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Plotting hexbins with Matplotlib.
77
88
Hexbin is an axes method or pyplot function that is essentially
9-
a pcolor of a 2-D histogram with hexagonal cells. It can be
9+
a pcolor of a 2D histogram with hexagonal cells. It can be
1010
much more informative than a scatter plot. In the first plot
1111
below, try substituting 'scatter' for 'hexbin'.
1212
"""

lib/matplotlib/_cm.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def cubehelix(gamma=1.0, s=0.5, r=-1.5, h=1.0):
7676
can be visualised as a squashed helix around the diagonal in the
7777
(r, g, b) color cube.
7878
79-
For a unit color cube (i.e. 3-D coordinates for (r, g, b) each in the
79+
For a unit color cube (i.e. 3D coordinates for (r, g, b) each in the
8080
range 0 to 1) the color scheme starts at (r, g, b) = (0, 0, 0), i.e. black,
8181
and finishes at (r, g, b) = (1, 1, 1), i.e. white. For some fraction *x*,
8282
between 0 and 1, the color is the corresponding grey value at that

lib/matplotlib/axes/_axes.py

+13-13
Original file line numberDiff line numberDiff line change
@@ -2028,11 +2028,11 @@ def step(self, x, y, *args, where='pre', data=None, **kwargs):
20282028
Parameters
20292029
----------
20302030
x : array-like
2031-
1-D sequence of x positions. It is assumed, but not checked, that
2031+
1D sequence of x positions. It is assumed, but not checked, that
20322032
it is uniformly increasing.
20332033
20342034
y : array-like
2035-
1-D sequence of y levels.
2035+
1D sequence of y levels.
20362036
20372037
fmt : str, optional
20382038
A format string, e.g. 'g' for a green line. See `.plot` for a more
@@ -4200,7 +4200,7 @@ def invalid_shape_exception(csize, xsize):
42004200
"RGBA sequence, which should be avoided as value-"
42014201
"mapping will have precedence in case its length "
42024202
"matches with *x* & *y*. Please use the *color* "
4203-
"keyword-argument or provide a 2-D array "
4203+
"keyword-argument or provide a 2D array "
42044204
"with a single row if you intend to specify "
42054205
"the same RGB or RGBA value for all points.")
42064206
valid_shape = False
@@ -4253,14 +4253,14 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
42534253
42544254
- A scalar or sequence of n numbers to be mapped to colors using
42554255
*cmap* and *norm*.
4256-
- A 2-D array in which the rows are RGB or RGBA.
4256+
- A 2D array in which the rows are RGB or RGBA.
42574257
- A sequence of colors of length n.
42584258
- A single color format string.
42594259
42604260
Note that *c* should not be a single numeric RGB or RGBA sequence
42614261
because that is indistinguishable from an array of values to be
42624262
colormapped. If you want to specify the same RGB or RGBA value for
4263-
all points, use a 2-D array with a single row. Otherwise, value-
4263+
all points, use a 2D array with a single row. Otherwise, value-
42644264
matching will have precedence in case of a size matching with *x*
42654265
and *y*.
42664266
@@ -4341,7 +4341,7 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
43414341
case all masks will be combined and only unmasked points will be
43424342
plotted.
43434343
4344-
* Fundamentally, scatter works with 1-D arrays; *x*, *y*, *s*, and *c*
4344+
* Fundamentally, scatter works with 1D arrays; *x*, *y*, *s*, and *c*
43454345
may be input as N-D arrays, but within scatter they will be
43464346
flattened. The exception is *c*, which will be flattened only if its
43474347
size matches the size of *x* and *y*.
@@ -5597,7 +5597,7 @@ def pcolor(self, *args, shading=None, alpha=None, norm=None, cmap=None,
55975597
Parameters
55985598
----------
55995599
C : array-like
5600-
A scalar 2-D array. The values will be color-mapped.
5600+
A scalar 2D array. The values will be color-mapped.
56015601
56025602
X, Y : array-like, optional
56035603
The coordinates of the corners of quadrilaterals of a pcolormesh::
@@ -5623,7 +5623,7 @@ def pcolor(self, *args, shading=None, alpha=None, norm=None, cmap=None,
56235623
color ``C[i, j]`` will be centered on ``(X[i, j], Y[i, j])``.
56245624
56255625
If *X* and/or *Y* are 1-D arrays or column vectors they will be
5626-
expanded as needed into the appropriate 2-D arrays, making a
5626+
expanded as needed into the appropriate 2D arrays, making a
56275627
rectangular grid.
56285628
56295629
shading : {'flat', 'nearest', 'auto'}, optional
@@ -5841,7 +5841,7 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
58415841
Parameters
58425842
----------
58435843
C : array-like
5844-
A scalar 2-D array. The values will be color-mapped.
5844+
A scalar 2D array. The values will be color-mapped.
58455845
58465846
X, Y : array-like, optional
58475847
The coordinates of the corners of quadrilaterals of a pcolormesh::
@@ -5869,7 +5869,7 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
58695869
interpolation is caried out between the quadrilateral corners.
58705870
58715871
If *X* and/or *Y* are 1-D arrays or column vectors they will be
5872-
expanded as needed into the appropriate 2-D arrays, making a
5872+
expanded as needed into the appropriate 2D arrays, making a
58735873
rectangular grid.
58745874
58755875
cmap : str or `~matplotlib.colors.Colormap`, default: :rc:`image.cmap`
@@ -5970,7 +5970,7 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
59705970
59715971
**Differences between pcolor() and pcolormesh()**
59725972
5973-
Both methods are used to create a pseudocolor plot of a 2-D array
5973+
Both methods are used to create a pseudocolor plot of a 2D array
59745974
using quadrilaterals.
59755975
59765976
The main difference lies in the created object and internal data
@@ -6300,7 +6300,7 @@ def hist(self, x, bins=None, range=None, density=False, weights=None,
63006300
63016301
Multiple data can be provided via *x* as a list of datasets
63026302
of potentially different length ([*x0*, *x1*, ...]), or as
6303-
a 2-D ndarray in which each column is a dataset. Note that
6303+
a 2D ndarray in which each column is a dataset. Note that
63046304
the ndarray form is transposed relative to the list form.
63056305
63066306
Masked arrays are not supported.
@@ -7478,7 +7478,7 @@ def specgram(self, x, NFFT=None, Fs=None, Fc=None, detrend=None,
74787478
74797479
Returns
74807480
-------
7481-
spectrum : 2-D array
7481+
spectrum : 2D array
74827482
Columns are the periodograms of successive segments.
74837483
74847484
freqs : 1-D array

lib/matplotlib/axes/_base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ def _plot_args(self, tup, kwargs, return_kwargs=False):
430430
raise ValueError(f"x and y must have same first dimension, but "
431431
f"have shapes {x.shape} and {y.shape}")
432432
if x.ndim > 2 or y.ndim > 2:
433-
raise ValueError(f"x and y can be no greater than 2-D, but have "
433+
raise ValueError(f"x and y can be no greater than 2D, but have "
434434
f"shapes {x.shape} and {y.shape}")
435435
if x.ndim == 1:
436436
x = x[:, np.newaxis]

lib/matplotlib/cbook/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1300,7 +1300,7 @@ def _to_unmasked_float_array(x):
13001300

13011301

13021302
def _check_1d(x):
1303-
"""Convert scalars to 1d arrays; pass-through arrays as is."""
1303+
"""Convert scalars to 1D arrays; pass-through arrays as is."""
13041304
if not hasattr(x, 'shape') or len(x.shape) < 1:
13051305
return np.atleast_1d(x)
13061306
else:

lib/matplotlib/cm.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ def to_rgba(self, x, alpha=None, bytes=False, norm=True):
295295
"""
296296
Return a normalized rgba array corresponding to *x*.
297297
298-
In the normal case, *x* is a 1-D or 2-D sequence of scalars, and
298+
In the normal case, *x* is a 1D or 2D sequence of scalars, and
299299
the corresponding ndarray of rgba values will be returned,
300300
based on the norm and colormap set for this ScalarMappable.
301301

lib/matplotlib/colors.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ class ColorConverter:
415415

416416
def _create_lookup_table(N, data, gamma=1.0):
417417
r"""
418-
Create an *N* -element 1-d lookup table.
418+
Create an *N* -element 1D lookup table.
419419
420420
This assumes a mapping :math:`f : [0, 1] \rightarrow [0, 1]`. The returned
421421
data is an array of N values :math:`y = f(x)` where x is sampled from
@@ -1795,7 +1795,7 @@ def hillshade(self, elevation, vert_exag=1, dx=1, dy=1, fraction=1.):
17951795
Parameters
17961796
----------
17971797
elevation : array-like
1798-
A 2d array (or equivalent) of the height values used to generate an
1798+
A 2D array (or equivalent) of the height values used to generate an
17991799
illumination map
18001800
vert_exag : number, optional
18011801
The amount to exaggerate the elevation values by when calculating
@@ -1817,7 +1817,7 @@ def hillshade(self, elevation, vert_exag=1, dx=1, dy=1, fraction=1.):
18171817
Returns
18181818
-------
18191819
ndarray
1820-
A 2d array of illumination values between 0-1, where 0 is
1820+
A 2D array of illumination values between 0-1, where 0 is
18211821
completely in shadow and 1 is completely illuminated.
18221822
"""
18231823

@@ -1860,7 +1860,7 @@ def shade_normals(self, normals, fraction=1.):
18601860
Returns
18611861
-------
18621862
ndarray
1863-
A 2d array of illumination values between 0-1, where 0 is
1863+
A 2D array of illumination values between 0-1, where 0 is
18641864
completely in shadow and 1 is completely illuminated.
18651865
"""
18661866

@@ -1893,7 +1893,7 @@ def shade(self, data, cmap, norm=None, blend_mode='overlay', vmin=None,
18931893
Parameters
18941894
----------
18951895
data : array-like
1896-
A 2d array (or equivalent) of the height values used to generate a
1896+
A 2D array (or equivalent) of the height values used to generate a
18971897
shaded map.
18981898
cmap : `~matplotlib.colors.Colormap`
18991899
The colormap used to color the *data* array. Note that this must be

lib/matplotlib/contour.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1564,7 +1564,7 @@ def _initialize_x_y(self, z):
15641564
X, Y : array-like, optional
15651565
The coordinates of the values in *Z*.
15661566
1567-
*X* and *Y* must both be 2-D with the same shape as *Z* (e.g.
1567+
*X* and *Y* must both be 2D with the same shape as *Z* (e.g.
15681568
created via `numpy.meshgrid`), or they must both be 1-D such
15691569
that ``len(X) == M`` is the number of columns in *Z* and
15701570
``len(Y) == N`` is the number of rows in *Z*.

lib/matplotlib/figure.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3229,7 +3229,7 @@ def figaspect(arg):
32293229
32303230
Parameters
32313231
----------
3232-
arg : float or 2d array
3232+
arg : float or 2D array
32333233
If a float, this defines the aspect ratio (i.e. the ratio height /
32343234
width).
32353235
In case of an array the aspect ratio is number of rows / number of

lib/matplotlib/image.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def composite_images(images, renderer, magnification=1.0):
7676
7777
Returns
7878
-------
79-
image : uint8 3d array
79+
image : uint8 array (M, N, 4)
8080
The composited RGBA image.
8181
offset_x, offset_y : float
8282
The (left, bottom) offset where the composited image should be placed

lib/matplotlib/mlab.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ def specgram(x, NFFT=None, Fs=None, detrend=None, window=None,
739739
Returns
740740
-------
741741
spectrum : array-like
742-
2-D array, columns are the periodograms of successive segments.
742+
2D array, columns are the periodograms of successive segments.
743743
744744
freqs : array-like
745745
1-D array, frequencies corresponding to the rows in *spectrum*.
@@ -841,7 +841,7 @@ class GaussianKDE:
841841
----------
842842
dataset : array-like
843843
Datapoints to estimate from. In case of univariate data this is a 1-D
844-
array, otherwise a 2-D array with shape (# of dims, # of data).
844+
array, otherwise a 2D array with shape (# of dims, # of data).
845845
846846
bw_method : str, scalar or callable, optional
847847
The method used to calculate the estimator bandwidth. This can be

lib/matplotlib/path.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def vertices(self, vertices):
216216
@property
217217
def codes(self):
218218
"""
219-
The list of codes in the `Path` as a 1-D numpy array. Each
219+
The list of codes in the `Path` as a 1D numpy array. Each
220220
code is one of `STOP`, `MOVETO`, `LINETO`, `CURVE3`, `CURVE4`
221221
or `CLOSEPOLY`. For codes that correspond to more than one
222222
vertex (`CURVE3` and `CURVE4`), that code will be repeated so

lib/matplotlib/stackplot.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ def stackplot(axes, x, *args,
2121
2222
Parameters
2323
----------
24-
x : 1d array of dimension N
24+
x : array-like (N)
2525
26-
y : 2d array (dimension MxN), or sequence of 1d arrays (each dimension 1xN)
26+
y : 2D array (M, N) or sequence of array-like (N)
2727
2828
The data is assumed to be unstacked. Each of the following
2929
calls is legal::
3030
31-
stackplot(x, y) # where y is MxN
32-
stackplot(x, y1, y2, y3, y4) # where y1, y2, y3, y4, are all 1xNm
31+
stackplot(x, y) # where y has shape (M, N)
32+
stackplot(x, y1, y2, y3) # where y1, y2, y3, y4 have length N
3333
3434
baseline : {'zero', 'sym', 'wiggle', 'weighted_wiggle'}
3535
Method used to calculate the baseline:
@@ -42,10 +42,10 @@ def stackplot(axes, x, *args,
4242
size of each layer. It is also called 'Streamgraph'-layout. More
4343
details can be found at http://leebyron.com/streamgraph/.
4444
45-
labels : Length N sequence of strings
45+
labels : Length N list of str
4646
Labels to assign to each data series.
4747
48-
colors : Length N sequence of colors
48+
colors : Length N list of color
4949
A list or tuple of colors. These will be cycled through and used to
5050
colour the stacked areas.
5151

lib/matplotlib/transforms.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1213,7 +1213,7 @@ class Transform(TransformNode):
12131213
12141214
The following attributes may be overridden if the default is unsuitable:
12151215
1216-
- :attr:`is_separable` (defaults to True for 1d -> 1d transforms, False
1216+
- :attr:`is_separable` (defaults to True for 1D -> 1D transforms, False
12171217
otherwise)
12181218
- :attr:`has_inverse` (defaults to True if :meth:`inverted` is overridden,
12191219
False otherwise)

lib/matplotlib/tri/triangulation.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def __init__(self, x, y, triangles=None, mask=None):
4141
self.x = np.asarray(x, dtype=np.float64)
4242
self.y = np.asarray(y, dtype=np.float64)
4343
if self.x.shape != self.y.shape or self.x.ndim != 1:
44-
raise ValueError("x and y must be equal-length 1-D arrays")
44+
raise ValueError("x and y must be equal-length 1D arrays")
4545

4646
self.mask = None
4747
self._edges = None

lib/matplotlib/tri/triinterpolate.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,9 @@ def _interpolate_single_key(self, return_key, tri_index, x, y):
215215
----------
216216
return_index : {'z', 'dzdx', 'dzdy'}
217217
Identifies the requested values (z or its derivatives)
218-
tri_index : 1d int array
218+
tri_index : 1D int array
219219
Valid triangle index (-1 prohibited)
220-
x, y : 1d arrays, same shape as `tri_index`
220+
x, y : 1D arrays, same shape as `tri_index`
221221
Valid locations where interpolation is requested.
222222
223223
Returns
@@ -290,7 +290,7 @@ class CubicTriInterpolator(TriInterpolator):
290290
291291
In one-dimension - on a segment - a cubic interpolating function is
292292
defined by the values of the function and its derivative at both ends.
293-
This is almost the same in 2-d inside a triangle, except that the values
293+
This is almost the same in 2D inside a triangle, except that the values
294294
of the function and its 2 derivatives have to be defined at each triangle
295295
node.
296296

lib/matplotlib/tri/trirefine.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def refine_field(self, z, triinterpolator=None, subdiv=3):
136136
137137
Parameters
138138
----------
139-
z : 1d-array-like of length ``n_points``
139+
z : array-like of length ``n_points``
140140
Values of the field to refine, defined at the nodes of the
141141
encapsulated triangulation. (``n_points`` is the number of points
142142
in the initial triangulation)
@@ -151,7 +151,7 @@ def refine_field(self, z, triinterpolator=None, subdiv=3):
151151
-------
152152
refi_tri : `~matplotlib.tri.Triangulation`
153153
The returned refined triangulation.
154-
refi_z : 1d array of length: *refi_tri* node count.
154+
refi_z : 1D array of length: *refi_tri* node count.
155155
The returned interpolated field (at *refi_tri* nodes).
156156
"""
157157
if triinterpolator is None:

0 commit comments

Comments
 (0)