8000 Merge pull request #14465 from anntzer/mplcolor · matplotlib/matplotlib@d49c7c0 · GitHub
[go: up one dir, main page]

Skip to content

Commit d49c7c0

Browse files
authored
Merge pull request #14465 from anntzer/mplcolor
Docstrings cleanups.
2 parents ad2607b + 9b2d78a commit d49c7c0

33 files changed

+123
-165
lines changed

doc/README.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ python documentation system built on top of ReST. This directory contains
3535

3636
* _templates - used by the sphinx build system
3737

38-
* sphinxext - Sphinx extensions for the mpl docs
38+
* sphinxext - Sphinx extensions for the Matplotlib docs

examples/images_contours_and_fields/image_annotated_heatmap.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def heatmap(data, row_labels, col_labels, ax=None,
161161

162162

163163
def annotate_heatmap(im, data=None, valfmt="{x:.2f}",
164-
textcolors=["black", "white"],
164+
textcolors=("black", "white"),
165165
threshold=None, **textkw):
166166
"""
167167
A function to annotate a heatmap.
@@ -177,8 +177,8 @@ def annotate_heatmap(im, data=None, valfmt="{x:.2f}",
177177
use the string format method, e.g. "$ {x:.2f}", or be a
178178
`matplotlib.ticker.Formatter`. Optional.
179179
textcolors
180-
A list or array of two color specifications. The first is used for
181-
values below a threshold, the second for those above. Optional.
180+
A pair of colors. The first is used for values below a threshold,
181+
the second for those above. Optional.
182182
threshold
183183
Value in data units according to which the colors from textcolors are
184184
applied. If None (the default) uses the middle of the colormap as
@@ -260,7 +260,7 @@ def annotate_heatmap(im, data=None, valfmt="{x:.2f}",
260260
im, _ = heatmap(data, y, x, ax=ax2, vmin=0,
261261
cmap="magma_r", cbarlabel="weekly sold copies")
262262
annotate_heatmap(im, valfmt="{x:d}", size=7, threshold=20,
263-
textcolors=["red", "white"])
263+
textcolors=("red", "white"))
264264

265265
# Sometimes even the data itself is categorical. Here we use a
266266
# :class:`matplotlib.colors.BoundaryNorm` to get the data into classes
@@ -281,7 +281,7 @@ def annotate_heatmap(im, data=None, valfmt="{x:.2f}",
281281
cbarlabel="Quality Rating")
282282

283283
annotate_heatmap(im, valfmt=fmt, size=9, fontweight="bold", threshold=-1,
284-
textcolors=["red", "black"])
284+
textcolors=("red", "black"))
285285

286286
# We can nicely plot a correlation matrix. Since this is bound by -1 and 1,
287287
# we use those as vmin and vmax. We may also remove leading zeros and hide

examples/misc/transoffset.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
(dots or inches) relative to a location given in any
1010
coordinates.
1111
12-
Every Artist--the mpl class from which classes such as
13-
Text and Line are derived--has a transform that can be
12+
Every Artist (Text, Line2D, etc.) has a transform that can be
1413
set when the Artist is created, such as by the corresponding
1514
pyplot command. By default this is usually the Axes.transData
1615
transform, going from data units to screen dots. We can

examples/text_labels_and_annotations/mathtext_examples.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656

5757

5858
def doall():
59-
# Colors used in mpl online documentation.
59+
# Colors used in Matplotlib online documentation.
6060
mpl_blue_rvb = (191. / 255., 209. / 256., 212. / 255.)
6161
mpl_orange_rvb = (202. / 255., 121. / 256., 0. / 255.)
6262
mpl_grey_rvb = (51. / 255., 51. / 255., 51. / 255.)

examples/user_interfaces/pylab_with_gtk_sgskip.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
toolitem.set_tooltip_text('Click me for fun and profit')
3737
toolitem.add(button)
3838

39-
pos = 8 # where to insert this in the mpl toolbar
39+
pos = 8 # where to insert this in the toolbar
4040
toolbar.insert(toolitem, pos)
4141

4242
# now let's add a widget to the vbox

lib/matplotlib/afm.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@
5151

5252
def _to_int(x):
5353
# Some AFM files have floats where we are expecting ints -- there is
54-
# probably a better way to handle this (support floats, round rather
55-
# than truncate). But I don't know what the best approach is now and
56-
# this change to _to_int should at least prevent mpl from crashing on
57-
# these JDH (2009-11-06)
54+
# probably a better way to handle this (support floats, round rather than
55+
# truncate). But I don't know what the best approach is now and this
56+
# change to _to_int should at least prevent Matplotlib from crashing on
57+
# these. JDH (2009-11-06)
5858
return int(float(x))
5959

6060

lib/matplotlib/axes/_axes.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3096,9 +3096,9 @@ def errorbar(self, x, y, yerr=None, xerr=None,
30963096
Use 'none' (case insensitive) to plot errorbars without any data
30973097
markers.
30983098
3099-
ecolor : mpl color, optional, default: None
3100-
A matplotlib color arg which gives the color the errorbar lines.
3101-
If None, use the color of the line connecting the markers.
3099+
ecolor : color, optional, default: None
3100+
The color of the errorbar lines. If None, use the color of the
3101+
line connecting the markers.
31023102
31033103
elinewidth : scalar, optional, default: None
31043104
The linewidth of the errorbar lines. If None, the linewidth of
@@ -4175,12 +4175,12 @@ def _parse_scatter_color_args(c, edgecolors, kwargs, xsize,
41754175
Returns
41764176
-------
41774177
c
4178-
The input *c* if it was not *None*, else some color specification
4179-
derived from the other inputs or defaults.
4178+
The input *c* if it was not *None*, else a color derived from the
4179+
other inputs or defaults.
41804180
colors : array(N, 4) or None
4181-
The facecolors as RGBA values or *None* if a colormap is used.
4181+
The facecolors as RGBA values, or *None* if a colormap is used.
41824182
edgecolors
4183-
The edgecolor specification.
4183+
The edgecolor.
41844184
41854185
"""
41864186
facecolors = kwargs.pop('facecolors', None)
@@ -4198,10 +4198,10 @@ def _parse_scatter_color_args(c, edgecolors, kwargs, xsize,
41984198
try:
41994199
mcolors.to_rgba_array(kwcolor)
42004200
except ValueError:
4201-
raise ValueError("'color' kwarg must be an mpl color"
4202-
" spec or sequence of color specs.\n"
4203-
"For a sequence of values to be color-mapped,"
4204-
" use the 'c' argument instead.")
4201+
raise ValueError(
4202+
"'color' kwarg must be an color or sequence of color "
4203+
"specs. For a sequence of values to be color-mapped, use "
4204+
"the 'c' argument instead.")
42054205
if edgecolors is None:
42064206
edgecolors = kwcolor
42074207
if facecolors is None:
@@ -4257,8 +4257,8 @@ def invalid_shape_exception(csize, xsize):
42574257
# Both the mapping *and* the RGBA conversion failed: pretty
42584258
# severe failure => one may appreciate a verbose feedback.
42594259
raise ValueError(
4260-
f"'c' argument must be a mpl color, a sequence of mpl "
4261-
f"colors, or a sequence of numbers, not {c}.")
4260+
f"'c' argument must be a color, a sequence of colors, or "
4261+
f"a sequence of numbers, not {c}")
42624262
else:
42634263
if len(colors) not in (0, 1, xsize):
42644264
# NB: remember that a single color is also acceptable.
@@ -4289,11 +4289,11 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
42894289
The marker size in points**2.
42904290
Default is ``rcParams['lines.markersize'] ** 2``.
42914291
4292-
c : color, sequence, or sequence of color, optional
4292+
c : color, sequence, or sequence of colors, optional
42934293
The marker color. Possible values:
42944294
42954295
- A single color format string.
4296-
- A sequence of color specifications of length n.
4296+
- A sequence of colors of length n.
42974297
- A scalar or sequence of n numbers to be mapped to colors using
42984298
*cmap* and *norm*.
42994299
- A 2-D array in which the rows are RGB or RGBA.
@@ -5759,7 +5759,7 @@ def pcolor(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
57595759
- *None*: :rc:`patch.edgecolor` will be used. Note that currently
57605760
:rc:`patch.force_edgecolor` has to be True for this to work.
57615761
- 'face': Use the adjacent face color.
5762-
- An mpl color or sequence of colors will set the edge color.
5762+
- A color or sequence of colors will set the edge color.
57635763
57645764
The singular form *edgecolor* works as an alias.
57655765
@@ -5993,7 +5993,7 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
59935993
- *None*: :rc:`patch.edgecolor` will be used. Note that currently
59945994
:rc:`patch.force_edgecolor` has to be True for this to work.
59955995
- 'face': Use the adjacent face color.
5996-
- An mpl color or sequence of colors will set the edge color.
5996+
- A color or sequence of colors will set the edge color.
59975997
59985998
The singular form *edgecolor* works as an alias.
59995999
@@ -6510,8 +6510,8 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
65106510
Default is ``False``
65116511
65126512
color : color or array_like of colors or None, optional
6513-
Color spec or sequence of color specs, one per dataset. Default
6514-
(``None``) uses the standard line color sequence.
6513+
Color or sequence of colors, one per dataset. Default (``None``)
6514+
uses the standard line color sequence.
65156515
65166516
Default is ``None``
65176517

lib/matplotlib/axes/_base.py

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2949,61 +2949,41 @@ def tick_params(self, axis='both', **kwargs):
29492949
----------------
29502950
axis : {'x', 'y', 'both'}
29512951
Axis on which to operate; default is 'both'.
2952-
2953-
reset : bool
2954-
If *True*, set all parameters to defaults
2955-
before processing other keyword arguments. Default is
2956-
*False*.
2957-
2952+
reset : bool, default: False
2953+
If *True*, set all parameters to defaults before processing other
2954+
keyword arguments.
29582955
which : {'major', 'minor', 'both'}
29592956
Default is 'major'; apply arguments to *which* ticks.
2960-
29612957
direction : {'in', 'out', 'inout'}
29622958
Puts ticks inside the axes, outside the axes, or both.
2963-
29642959
length : float
29652960
Tick length in points.
2966-
29672961
width : float
29682962
Tick width in points.
2969-
29702963
color : color
2971-
Tick color; accepts any mpl color spec.
2972-
2964+
Tick color.
29732965
pad : float
29742966
Distance in points between tick and label.
2975-
29762967
labelsize : float or str
29772968
Tick label font size in points or as a string (e.g., 'large').
2978-
29792969
labelcolor : color
2980-
Tick label color; mpl color spec.
2981-
2970+
Tick label color.
29822971
colors : color
2983-
Changes the tick color and the label color to the same value:
2984-
mpl color spec.
2985-
2972+
Tick color and label color.
29862973
zorder : float
29872974
Tick and label zorder.
2988-
29892975
bottom, top, left, right : bool
29902976
Whether to draw the respective ticks.
2991-
29922977
labelbottom, labeltop, labelleft, labelright : bool
29932978
Whether to draw the respective tick labels.
2994-
29952979
labelrotation : float
29962980
Tick label rotation
2997-
29982981
grid_color : color
2999-
Changes the gridline color to the given mpl color spec.
3000-
2982+
Gridline color.
30012983
grid_alpha : float
30022984
Transparency of gridlines: 0 (transparent) to 1 (opaque).
3003-
30042985
grid_linewidth : float
30052986
Width of gridlines in points.
3006-
30072987
grid_linestyle : string
30082988
Any valid `~matplotlib.lines.Line2D` line style spec.
30092989

lib/matplotlib/backend_bases.py

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1776,15 +1776,12 @@ def button_release_event(self, x, y, button, guiEvent=None):
17761776
17771777
Parameters
17781778
----------
1779-
x : scalar
1780-
the canvas coordinates where 0=left
1781-
1782-
y : scalar
1783-
the canvas coordinates where 0=bottom
1784-
1779+
x : float
1780+
The canvas coordinates where 0=left.
1781+
y : float
1782+
The canvas coordinates where 0=bottom.
17851783
guiEvent
1786-
the native UI event that generated the mpl event
1787-
1784+
The native UI event that generated the Matplotlib event.
17881785
"""
17891786
s = 'button_release_event'
17901787
event = MouseEvent(s, self, x, y, button, self._key, guiEvent=guiEvent)
@@ -1801,15 +1798,12 @@ def motion_notify_event(self, x, y, guiEvent=None):
18011798
18021799
Parameters
18031800
----------
1804-
x : scalar
1805-
the canvas coordinates where 0=left
1806-
1807-
y : scalar
1808-
the canvas coordinates where 0=bottom
1809-
1801+
x : float
1802+
The canvas coordinates where 0=left.
1803+
y : float
1804+
The canvas coordinates where 0=bottom.
18101805
guiEvent
1811-
the native UI event that generated the mpl event
1812-
1806+
The native UI event that generated the Matplotlib event.
18131807
"""
18141808
self._lastx, self._lasty = x, y
18151809
s = 'motion_notify_event'
@@ -1825,10 +1819,8 @@ def leave_notify_event(self, guiEvent=None):
18251819
Parameters
18261820
----------
18271821
guiEvent
1828-
the native UI event that generated the mpl event
1829-
1822+
The native UI event that generated the Matplotlib event.
18301823
"""
1831-
18321824
self.callbacks.process('figure_leave_event', LocationEvent.lastevent)
18331825
LocationEvent.lastevent = None
18341826
self._lastx, self._lasty = None, None
@@ -1841,11 +1833,9 @@ def enter_notify_event(self, guiEvent=None, xy=None):
18411833
Parameters
18421834
----------
18431835
guiEvent
1844-
the native UI event that generated the mpl event
1836+
The native UI event that generated the Matplotlib event.
18451837
xy : (float, float)
1846-
the coordinate location of the pointer when the canvas is
1847-
entered
1848-
1838+
The coordinate location of the pointer when the canvas is entered.
18491839
"""
18501840
if xy is not None:
18511841
x, y = xy
@@ -2289,8 +2279,8 @@ def stop_event_loop(self):
22892279

22902280
def key_press_handler(event, canvas, toolbar=None):
22912281
"""
2292-
Implement the default mpl key bindings for the canvas and toolbar
2293-
described at :ref:`key-event-handling`
2282+
Implement the default Matplotlib key bindings for the canvas and toolbar
2283+
described at :ref:`key-event-handling`.
22942284
22952285
Parameters
22962286
----------
@@ -2300,7 +2290,6 @@ def key_press_handler(event, canvas, toolbar=None):
23002290
the backend-specific canvas instance
23012291
toolbar : :class:`NavigationToolbar2`
23022292
the navigation cursor toolbar
2303-
23042293
"""
23052294
# these bindings happen whether you are over an axes or not
23062295

@@ -2541,8 +2530,8 @@ def resize(self, w, h):
25412530

25422531
def key_press(self, event):
25432532
"""
2544-
Implement the default mpl key bindings defined at
2545-
:ref:`key-event-handling`
2533+
Implement the default Matplotlib key bindings defined at
2534+
:ref:`key-event-handling`.
25462535
"""
25472536
if rcParams['toolbar'] != 'toolmanager':
25482537
key_press_handler(event, self.canvas, self.canvas.toolbar)

lib/matplotlib/backends/_backend_tk.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -880,9 +880,9 @@ def new_figure_manager_given_figure(cls, num, figure):
880880
window = tk.Tk(className="matplotlib")
881881
window.withdraw()
882882

883-
# Put a mpl icon on the window rather than the default tk icon.
884-
# Tkinter doesn't allow colour icons on linux systems, but tk>=8.5
885-
# has a iconphoto command which we call directly. Source:
883+
# Put a Matplotlib icon on the window rather than the default tk
884+
# icon. Tkinter doesn't allow colour icons on linux systems, but
885+
# tk>=8.5 has a iconphoto command which we call directly. See
886886
# http://mail.python.org/pipermail/tkinter-discuss/2006-November/000954.html
887887
icon_fname = str(cbook._get_data_path('images/matplotlib.ppm'))
888888
icon_img = tk.PhotoImage(file=icon_fname, master=window)

lib/matplotlib/backends/backend_qt5.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
QtCore.Qt.Key_Clear: 'clear', }
6060

6161
# define which modifier keys are collected on keyboard events.
62-
# elements are (mpl names, Modifier Flag, Qt Key) tuples
62+
# elements are (Matplotlib modifier names, Modifier Flag, Qt Key) tuples
6363
SUPER = 0
6464
ALT = 1
6565
CTRL = 2

lib/matplotlib/backends/backend_webagg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def __init__(self, url_prefix=''):
171171
tornado.web.StaticFileHandler,
172172
{'path': core.FigureManagerWebAgg.get_static_file_path()}),
173173

174-
# An MPL favicon
174+
# A Matplotlib favicon
175175
(url_prefix + r'/favicon.ico', self.FavIcon),
176176

177177
# The page that contains all of the pieces

0 commit comments

Comments
 (0)
0