Skip to content

Commit 075ff09

Browse files
committed
Small style fixes.
1 parent 2e921df commit 075ff09

File tree

21 files changed

+77
-105
lines changed

21 files changed

+77
-105
lines changed

doc/devel/MEP/MEP26.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Detailed description
3434
====================
3535

3636
Currently, the look and appearance of existing artist objects (figure,
37-
axes, Line2D etc...) can only be updated via ``set_`` and ``get_`` methods
37+
axes, Line2D, etc.) can only be updated via ``set_`` and ``get_`` methods
3838
on the artist object, which is quite laborious, especially if no
3939
reference to the artist(s) has been stored. The new style sheets
4040
introduced in 1.4 allow styling before a plot is created, but do not
@@ -51,7 +51,7 @@ of primitives.
5151
The new methodology would require development of a number of steps:
5252

5353
- A new stylesheet syntax (likely based on CSS) to allow selection of
54-
artists by type, class, id etc...
54+
artists by type, class, id, etc.
5555
- A mechanism by which to parse a stylesheet into a tree
5656
- A mechanism by which to translate the parse-tree into something
5757
which can be used to update the properties of relevant

doc/devel/documenting_mpl.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ Keyword arguments
675675

676676
Since Matplotlib uses a lot of pass-through ``kwargs``, e.g., in every function
677677
that creates a line (`~.pyplot.plot`, `~.pyplot.semilogx`, `~.pyplot.semilogy`,
678-
etc...), it can be difficult for the new user to know which ``kwargs`` are
678+
etc.), it can be difficult for the new user to know which ``kwargs`` are
679679
supported. Matplotlib uses a docstring interpolation scheme to support
680680
documentation of every function that takes a ``**kwargs``. The requirements
681681
are:

examples/event_handling/pick_event_demo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
===============
55
66
You can enable picking by setting the "picker" property of an artist
7-
(for example, a matplotlib Line2D, Text, Patch, Polygon, AxesImage,
8-
etc...)
7+
(for example, a Matplotlib Line2D, Text, Patch, Polygon, AxesImage,
8+
etc.)
99
1010
There are a variety of meanings of the picker property:
1111

examples/misc/custom_projection.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -270,14 +270,8 @@ def format_coord(self, lon, lat):
270270
In this case, we want them to be displayed in degrees N/S/E/W.
271271
"""
272272
lon, lat = np.rad2deg([lon, lat])
273-
if lat >= 0.0:
274-
ns = 'N'
275-
else:
276-
ns = 'S'
277-
if lon >= 0.0:
278-
ew = 'E'
279-
else:
280-
ew = 'W'
273+
ns = 'N' if lat >= 0.0 else 'S'
274+
ew = 'E' if lon >= 0.0 else 'W'
281275
return ('%f\N{DEGREE SIGN}%s, %f\N{DEGREE SIGN}%s'
282276
% (abs(lat), ns, abs(lon), ew))
283277

examples/text_labels_and_annotations/usetex_fonteffects.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ def setfont(font):
1515

1616

1717
fig = plt.figure()
18-
for y, font, text in zip(range(5),
19-
['ptmr8r', 'ptmri8r', 'ptmro8r',
20-
'ptmr8rn', 'ptmrr8re'],
21-
['Nimbus Roman No9 L ' + x for x in
22-
['', 'Italics (real italics for comparison)',
23-
'(slanted)', '(condensed)', '(extended)']]):
18+
for y, font, text in zip(
19+
range(5),
20+
['ptmr8r', 'ptmri8r', 'ptmro8r', 'ptmr8rn', 'ptmrr8re'],
21+
[f'Nimbus Roman No9 L {x}'
22+
for x in ['', 'Italics (real italics for comparison)',
23+
'(slanted)', '(condensed)', '(extended)']],
24+
):
2425
fig.text(.1, 1 - (y + 1) / 6, setfont(font) + text, usetex=True)
2526

2627
fig.suptitle('Usetex font effects')

examples/user_interfaces/toolmanager_sgskip.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,26 @@
33
Tool Manager
44
============
55
6-
This example demonstrates how to:
6+
This example demonstrates how to
77
8-
* Modify the Toolbar
9-
* Create tools
10-
* Add tools
11-
* Remove tools
8+
* modify the Toolbar
9+
* create tools
10+
* add tools
11+
* remove tools
1212
13-
Using `matplotlib.backend_managers.ToolManager`
13+
using `matplotlib.backend_managers.ToolManager`.
1414
"""
1515

1616
import matplotlib.pyplot as plt
17-
plt.rcParams['toolbar'] = 'toolmanager'
1817
from matplotlib.backend_tools import ToolBase, ToolToggleBase
1918

2019

20+
plt.rcParams['toolbar'] = 'toolmanager'
21+
22+
2123
class ListTools(ToolBase):
2224
"""List all the tools controlled by the `ToolManager`."""
23-
# keyboard shortcut
24-
default_keymap = 'm'
25+
default_keymap = 'm' # keyboard shortcut
2526
description = 'List Tools'
2627

2728
def trigger(self, *args, **kwargs):
@@ -77,7 +78,6 @@ def set_lines_visibility(self, state):
7778
fig.canvas.manager.toolmanager.add_tool('List', ListTools)
7879
fig.canvas.manager.toolmanager.add_tool('Show', GroupHideTool, gid='mygroup')
7980

80-
8181
# Add an existing tool to new group `foo`.
8282
# It can be added as many times as we want
8383
fig.canvas.manager.toolbar.add_tool('zoom', 'foo')

examples/userdemo/anchored_box04.py

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

1313
fig, ax = plt.subplots(figsize=(3, 3))
1414

15-
box1 = TextArea(" Test : ", textprops=dict(color="k"))
15+
box1 = TextArea(" Test: ", textprops=dict(color="k"))
1616

1717
box2 = DrawingArea(60, 20, 0, 0)
1818
el1 = Ellipse((10, 10), width=16, height=5, angle=30, fc="r")

lib/matplotlib/axes/_base.py

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2878,26 +2878,23 @@ def handle_single_axis(
28782878
shared = shared_axes.get_siblings(self)
28792879
# Base autoscaling on finite data limits when there is at least one
28802880
# finite data limit among all the shared_axes and intervals.
2881-
# Also, find the minimum minpos for use in the margin calculation.
2882-
x_values = []
2883-
minimum_minpos = np.inf
2884-
for ax in shared:
2885-
x_values.extend(getattr(ax.dataLim, f"interval{name}"))
2886-
minimum_minpos = min(minimum_minpos,
2887-
getattr(ax.dataLim, f"minpos{name}"))
2888-
x_values = np.extract(np.isfinite(x_values), x_values)
2889-
if x_values.size >= 1:
2890-
x0, x1 = (x_values.min(), x_values.max())
2881+
values = [val for ax in shared
2882+
for val in getattr(ax.dataLim, f"interval{name}")
2883+
if np.isfinite(val)]
2884+
if values:
2885+
x0, x1 = (min(values), max(values))
28912886
elif getattr(self._viewLim, f"mutated{name}")():
28922887
# No data, but explicit viewLims already set:
28932888
# in mutatedx or mutatedy.
28942889
return
28952890
else:
28962891
x0, x1 = (-np.inf, np.inf)
2897-
# If x0 and x1 are non finite, use the locator to figure out
2898-
# default limits.
2892+
# If x0 and x1 are nonfinite, get default limits from the locator.
28992893
locator = axis.get_major_locator()
29002894
x0, x1 = locator.nonsingular(x0, x1)
2895+
# Find the minimum minpos for use in the margin calculation.
2896+
minimum_minpos = min(
2897+
getattr(ax.dataLim, f"minpos{name}") for ax in shared)
29012898

29022899
# Prevent margin addition from crossing a sticky value. A small
29032900
# tolerance must be added due to floating point issues with
@@ -4027,15 +4024,10 @@ def format_ydata(self, y):
40274024

40284025
def format_coord(self, x, y):
40294026
"""Return a format string formatting the *x*, *y* coordinates."""
4030-
if x is None:
4031-
xs = '???'
4032-
else:
4033-
xs = self.format_xdata(x)
4034-
if y is None:
4035-
ys = '???'
4036-
else:
4037-
ys = self.format_ydata(y)
4038-
return 'x=%s y=%s' % (xs, ys)
4027+
return "x={} y={}".format(
4028+
"???" if x is None else self.format_xdata(x),
4029+
"???" if y is None else self.format_ydata(y),
4030+
)
40394031

40404032
def minorticks_on(self):
40414033
"""

lib/matplotlib/backends/backend_svg.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -459,10 +459,7 @@ def _make_id(self, type, content):
459459
return '%s%s' % (type, m.hexdigest()[:10])
460460

461461
def _make_flip_transform(self, transform):
462-
return (transform +
463-
Affine2D()
464-
.scale(1.0, -1.0)
465-
.translate(0.0, self.height))
462+
return transform + Affine2D().scale(1, -1).translate(0, self.height)
466463

467464
def _get_font(self, prop):
468465
fname = fm.findfont(prop)

lib/matplotlib/backends/backend_template.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def points_to_pixels(self, points):
108108

109109
class GraphicsContextTemplate(GraphicsContextBase):
110110
"""
111-
The graphics context provides the color, line styles, etc... See the cairo
111+
The graphics context provides the color, line styles, etc. See the cairo
112112
and postscript backends for examples of mapping the graphics context
113113
attributes (cap styles, join styles, line widths, colors) to a particular
114114
backend. In cairo this is done by wrapping a cairo.Context object and
@@ -131,7 +131,7 @@ class GraphicsContextTemplate(GraphicsContextBase):
131131
########################################################################
132132
#
133133
# The following functions and classes are for pyplot and implement
134-
# window/figure managers, etc...
134+
# window/figure managers, etc.
135135
#
136136
########################################################################
137137

0 commit comments

Comments
 (0)