8000 mpl_toolkits style fixes. by anntzer · Pull Request #13396 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

mpl_toolkits style fixes. #13396

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
Feb 10, 2019
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
6 changes: 1 addition & 5 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,13 @@ per-file-ignores =
lib/matplotlib/tri/triinterpolate.py: E201, E221
lib/matplotlib/type1font.py: E731

lib/mpl_toolkits/axes_grid/axes_rgb.py: E501
lib/mpl_toolkits/axes_grid1/axes_divider.py: E402, E501
lib/mpl_toolkits/axes_grid1/axes_grid.py: E225
lib/mpl_toolkits/axes_grid1/axes_size.py: E272, E501
lib/mpl_toolkits/axes_grid1/axes_size.py: E272
lib/mpl_toolkits/axes_grid1/colorbar.py: E225, E501
lib/mpl_toolkits/axes_grid1/inset_locator.py: E501
lib/mpl_toolkits/axisartist/angle_helper.py: E221
lib/mpl_toolkits/axisartist/clip_path.py: E225
lib/mpl_toolkits/axisartist/floating_axes.py: E225, E402, E501
lib/mpl_toolkits/axisartist/grid_helper_curvelinear.py: E225, E501
lib/mpl_toolkits/tests/test_axes_grid1.py: E201, E202

doc/conf.py: E402, E501
doc/sphinxext/github.py: E302, E501
Expand Down
6 changes: 2 additions & 4 deletions lib/mpl_toolkits/axes_grid/axes_rgb.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#from mpl_toolkits.axes_grid1.axes_rgb import *
from mpl_toolkits.axes_grid1.axes_rgb import make_rgb_axes, imshow_rgb, RGBAxesBase

#import mpl_toolkits.axes_grid1.axes_rgb as axes_rgb_orig
from mpl_toolkits.axes_grid1.axes_rgb import (
make_rgb_axes, imshow_rgb, RGBAxesBase)
from mpl_toolkits.axisartist.axislines import Axes


Expand Down
31 changes: 8 additions & 23 deletions lib/mpl_toolkits/axes_grid1/axes_divider.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
object that can be used to set the axes_locator of the axes.
"""

import matplotlib.transforms as mtransforms
from matplotlib import cbook
from matplotlib.axes import SubplotBase
from matplotlib.gridspec import SubplotSpec, GridSpec
import matplotlib.transforms as mtransforms
from . import axes_size as Size


Expand Down Expand Up @@ -347,9 +348,6 @@ def get_subplotspec(self):
return None


from matplotlib.gridspec import SubplotSpec, GridSpec


class SubplotDivider(Divider):
"""
The Divider class whose rectangle area is specified as a subplot geometry.
Expand Down Expand Up @@ -539,32 +537,26 @@ def new_horizontal(self, size, pad=None, pack_start=False, **kwargs):
instance of the given class. Otherwise, the same class of the
main axes will be used.
"""

if pad:
if not isinstance(pad, Size._Base):
pad = Size.from_any(pad,
fraction_ref=self._xref)
pad = Size.from_any(pad, fraction_ref=self._xref)
if pack_start:
self._horizontal.insert(0, pad)
self._xrefindex += 1
else:
self._horizontal.append(pad)

if not isinstance(size, Size._Base):
size = Size.from_any(size,
fraction_ref=self._xref)

size = Size.from_any(size, fraction_ref=self._xref)
if pack_start:
self._horizontal.insert(0, size)
self._xrefindex += 1
locator = self.new_locator(nx=0, ny=self._yrefindex)
else:
self._horizontal.append(size)
locator = self.new_locator(nx=len(self._horizontal)-1, ny=self._yrefindex)

locator = self.new_locator(
nx=len(self._horizontal) - 1, ny=self._yrefindex)
ax = self._get_new_axes(**kwargs)
ax.set_axes_locator(locator)

return ax

def new_vertical(self, size, pad=None, pack_start=False, **kwargs):
Expand All @@ -589,32 +581,25 @@ def new_vertical(self, size, pad=None, pack_start=False, **kwargs):
instance of the given class. Otherwise, the same class of the
main axes will be used.
"""

if pad:
if not isinstance(pad, Size._Base):
pad = Size.from_any(pad,
fraction_ref=self._yref)
pad = Size.from_any(pad, fraction_ref=self._yref)
if pack_start:
self._vertical.insert(0, pad)
self._yrefindex += 1
else:
self._vertical.append(pad)

if not isinstance(size, Size._Base):
size = Size.from_any(size,
fraction_ref=self._yref)

size = Size.from_any(size, fraction_ref=self._yref)
if pack_start:
self._vertical.insert(0, size)
self._yrefindex += 1
locator = self.new_locator(nx=self._xrefindex, ny=0)
else:
self._vertical.append(size)
locator = self.new_locator(nx=self._xrefindex, ny=len(self._vertical)-1)

ax = self._get_new_axes(**kwargs)
ax.set_axes_locator(locator)

return ax

def append_axes(self, position, size, pad=None, add_to_figure=True,
Expand Down
2 changes: 1 addition & 1 deletion lib/mpl_toolkits/axes_grid1/axes_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ def _update_locators(self):
(self._colorbar_location == 'right'
and col == self._ncols-1)):
locator = self._divider.new_locator(
nx=h_cb_pos[0], ny=v_ax_pos[self._nrows -1 - row])
nx=h_cb_pos[0], ny=v_ax_pos[self._nrows - 1 - row])
self.cbar_axes[row].set_axes_locator(locator)
elif ((self._colorbar_location == 'bottom' and
row == self._nrows - 1) or
Expand Down
10 changes: 8 additions & 2 deletions lib/mpl_toolkits/axes_grid1/axes_size.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ def get_size(self, renderer):


class Fixed(_Base):
"Simple fixed size with absolute part = *fixed_size* and relative part = 0"
"""
Simple fixed size with absolute part = *fixed_size* and relative part = 0.
"""
def __init__(self, fixed_size):
self.fixed_size = fixed_size

Expand All @@ -63,7 +65,11 @@ def get_size(self, renderer):


class Scaled(_Base):
"Simple scaled(?) size with absolute part = 0 and relative part = *scalable_size*"
"""
Simple scaled(?) size with absolute part = 0 and
relative part = *scalable_size*.
"""

def __init__(self, scalable_size):
self._scalable_size = scalable_size

Expand Down
17 changes: 8 additions & 9 deletions lib/mpl_toolkits/axes_grid1/inset_locator.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,11 @@ def __init__(self, parent_axes, zoom, loc,
def get_extent(self, renderer):
bb = TransformedBbox(self.axes.viewLim,
self.parent_axes.transData)

x, y, w, h = bb.bounds
fontsize = renderer.points_to_pixels(self.prop.get_size_in_points())
pad = self.pad * fontsize

return abs(w * self.zoom) + 2 * pad, abs(h * self.zoom) + 2 * pad, pad, pad
return (abs(w * self.zoom) + 2 * pad, abs(h * self.zoom) + 2 * pad,
pad, pad)


class BboxPatch(Patch):
Expand Down Expand Up @@ -308,7 +307,7 @@ def __init__(self, bbox1, bbox2, loc1, loc2=None, **kwargs):
if 'fill' in kwargs:
Patch.__init__(self, **kwargs)
else:
fill = ('fc' in kwargs) or ('facecolor' in kwargs) or ('color' in kwargs)
fill = bool({'fc', 'facecolor', 'color'}.intersection(kwargs))
Patch.__init__(self, fill=fill, **kwargs)
self.bbox1 = bbox1
self.bbox2 = bbox2
Expand All @@ -328,10 +327,10 @@ def __init__(self, bbox1, bbox2, loc1a, loc2a, loc1b, loc2b, **kwargs):
"""
Connect two bboxes with a quadrilateral.

The quadrilateral is specified by two lines that start and end at corners
of the bboxes. The four sides of the quadrilateral are defined by the two
lines given, the line between the two corners specified in *bbox1* and the
line between the two corners specified in *bbox2*.
The quadrilateral is specified by two lines that start and end at
corners of the bboxes. The four sides of the quadrilateral are defined
by the two lines given, the line between the two corners specified in
*bbox1* and the line between the two corners specified in *bbox2*.

Parameters
----------
Expand Down Expand Up @@ -666,7 +665,7 @@ def mark_inset(parent_axes, inset_axes, loc1, loc2, **kwargs):
if 'fill' in kwargs:
pp = BboxPatch(rect, **kwargs)
else:
fill = ('fc' in kwargs) or ('facecolor' in kwargs) or ('color' in kwargs)
fill = bool({'fc', 'facecolor', 'color'}.intersection(kwargs))
pp = BboxPatch(rect, fill=fill, **kwargs)
parent_axes.add_patch(pp)

Expand Down
6 changes: 3 additions & 3 deletions lib/mpl_toolkits/tests/test_axes_grid1.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ def test_twin_axes_empty_and_removed():
matplotlib.rcParams.update({"font.size": 8})
matplotlib.rcParams.update({"xtick.labelsize": 8})
matplotlib.rcParams.update({"ytick.labelsize": 8})
generators = [ "twinx", "twiny", "twin" ]
modifiers = [ "", "host invisible", "twin removed", "twin invisible",
"twin removed\nhost invisible" ]
generators = ["twinx", "twiny", "twin"]
modifiers = ["", "host invisible", "twin removed", "twin invisible",
"twin removed\nhost invisible"]
# Unmodified host subplot at the beginning for reference
h = host_subplot(len(modifiers)+1, len(generators), 2)
h.text(0.5, 0.5, "host_subplot", horizontalalignment="center",
Expand Down
0