Skip to content

Commit fad6deb

Browse files
authored
Merge pull request #9055 from anntzer/cleanup
Small cleanups.
2 parents 7dd60e9 + 5eace1e commit fad6deb

File tree

5 files changed

+79
-114
lines changed

5 files changed

+79
-114
lines changed

lib/matplotlib/axes/_base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,8 @@ class _AxesBase(martist.Artist):
414414
_shared_y_axes = cbook.Grouper()
415415

416416
def __str__(self):
417-
return "Axes(%g,%g;%gx%g)" % tuple(self._position.bounds)
417+
return "{0}({1[0]:g},{1[1]:g};{1[2]:g}x{1[3]:g})".format(
418+
type(self).__name__, self._position.bounds)
418419

419420
def __init__(self, fig, rect,
420421
facecolor=None, # defaults to rc axes.facecolor

lib/matplotlib/backend_tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ class ToolHome(ViewsPositionsBase):
732732
class ToolBack(ViewsPositionsBase):
733733
"""Move back up the view lim stack"""
734734

735-
description = 'Back to previous view'
735+
description = 'Back to previous view'
736736
image = 'back.png'
737737
default_keymap = rcParams['keymap.back']
738738
_on_trigger = 'back'

lib/matplotlib/figure.py

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,7 @@ def add_axes(self, *args, **kwargs):
960960
# check that an axes of this type doesn't already exist, if it
961961
# does, set it as active and return it
962962
ax = self._axstack.get(key)
963-
if ax is not None and isinstance(ax, projection_class):
963+
if isinstance(ax, projection_class):
964964
self.sca(ax)
965965
return ax
966966

@@ -1862,12 +1862,10 @@ def subplots_adjust(self, *args, **kwargs):
18621862
for ax in self.axes:
18631863
if not isinstance(ax, SubplotBase):
18641864
# Check if sharing a subplots axis
1865-
if (ax._sharex is not None and
1866-
isinstance(ax._sharex, SubplotBase)):
1865+
if isinstance(ax._sharex, SubplotBase):
18671866
ax._sharex.update_params()
18681867
ax.set_position(ax._sharex.figbox)
1869-
elif (ax._sharey is not None and
1870-
isinstance(ax._sharey, SubplotBase)):
1868+
elif isinstance(ax._sharey, SubplotBase):
18711869
ax._sharey.update_params()
18721870
ax.set_position(ax._sharey.figbox)
18731871
else:
@@ -1974,8 +1972,8 @@ def get_tightbbox(self, renderer):
19741972

19751973
return bbox_inches
19761974

1977-
def tight_layout(self, renderer=None, pad=1.08, h_pad=None,
1978-
w_pad=None, rect=None):
1975+
def tight_layout(self, renderer=None, pad=1.08, h_pad=None, w_pad=None,
1976+
rect=None):
19791977
"""
19801978
Adjust subplot parameters to give specified padding.
19811979
@@ -1993,23 +1991,20 @@ def tight_layout(self, renderer=None, pad=1.08, h_pad=None,
19931991
labels) will fit into. Default is (0, 0, 1, 1).
19941992
"""
19951993

1996-
from .tight_layout import (get_renderer, get_tight_layout_figure,
1997-
get_subplotspec_list)
1994+
from .tight_layout import (
1995+
get_renderer, get_subplotspec_list, get_tight_layout_figure)
19981996

19991997
subplotspec_list = get_subplotspec_list(self.axes)
20001998
if None in subplotspec_list:
2001-
warnings.warn("This figure includes Axes that are not "
2002-
"compatible with tight_layout, so its "
2003-
"results might be incorrect.")
1999+
warnings.warn("This figure includes Axes that are not compatible "
2000+
"with tight_layout, so results might be incorrect.")
20042001

20052002
if renderer is None:
20062003
renderer = get_renderer(self)
20072004

2008-
kwargs = get_tight_layout_figure(self, self.axes, subplotspec_list,
2009-
renderer,
2010-
pad=pad, h_pad=h_pad, w_pad=w_pad,
2011-
rect=rect)
2012-
2005+
kwargs = get_tight_layout_figure(
2006+
self, self.axes, subplotspec_list, renderer,
2007+
pad=pad, h_pad=h_pad, w_pad=w_pad, rect=rect)
20132008
self.subplots_adjust(**kwargs)
20142009

20152010

0 commit comments

Comments
 (0)