Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b751ccc

Browse files
committed
Cleanup axislines style.
1 parent 46ba49a commit b751ccc

File tree

2 files changed

+34
-32
lines changed

2 files changed

+34
-32
lines changed

.flake8

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ per-file-ignores =
5757
mpl_toolkits/axes_grid1/inset_locator.py: E501
5858
mpl_toolkits/axes_grid1/mpl_axes.py: E501
5959
mpl_toolkits/axisartist/angle_helper.py: E221
60-
mpl_toolkits/axisartist/axislines.py: E225, E501
6160
mpl_toolkits/axisartist/clip_path.py: E225, E501
6261
mpl_toolkits/axisartist/floating_axes.py: E225, E402, E501
6362
mpl_toolkits/axisartist/grid_helper_curvelinear.py: E225, E501

lib/mpl_toolkits/axisartist/axislines.py

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@
55
class. Originally, this change was motivated to support curvilinear
66
grid. Here are a few reasons that I came up with a new axes class:
77
8+
* "top" and "bottom" x-axis (or "left" and "right" y-axis) can have
9+
different ticks (tick locations and labels). This is not possible
10+
with the current mpl, although some twin axes trick can help.
811
9-
* "top" and "bottom" x-axis (or "left" and "right" y-axis) can have
10-
different ticks (tick locations and labels). This is not possible
11-
with the current mpl, although some twin axes trick can help.
12+
* Curvilinear grid.
1213
13-
* Curvilinear grid.
14-
15-
* angled ticks.
14+
* angled ticks.
1615
1716
In the new axes class, xaxis and yaxis is set to not visible by
1817
default, and new set of artist (AxisArtist) are defined to draw axis
@@ -24,11 +23,11 @@
2423
AxisArtist can be considered as a container artist and
2524
has following children artists which will draw ticks, labels, etc.
2625
27-
* line
28-
* major_ticks, major_ticklabels
29-
* minor_ticks, minor_ticklabels
30-
* offsetText
31-
* label
26+
* line
27+
* major_ticks, major_ticklabels
28+
* minor_ticks, minor_ticklabels
29+
* offsetText
30+
* label
3231
3332
Note that these are separate artists from Axis class of the
3433
original mpl, thus most of tick-related command in the original mpl
@@ -198,7 +197,8 @@ def get_nth_coord(self):
198197
return self.nth_coord
199198

200199
def get_line(self, axes):
201-
raise RuntimeError("get_line method should be defined by the derived class")
200+
raise RuntimeError(
201+
"get_line method should be defined by the derived class")
202202

203203

204204
class AxisArtistHelperRectlinear(object):
@@ -228,12 +228,14 @@ def get_tick_iterators(self, axes):
228228
major = self.axis.major
229229
majorLocs = major.locator()
230230
major.formatter.set_locs(majorLocs)
231-
majorLabels = [major.formatter(val, i) for i, val in enumerate(majorLocs)]
231+
majorLabels = [major.formatter(val, i)
232+
for i, val in enumerate(majorLocs)]
232233

233234
minor = self.axis.minor
234235
minorLocs = minor.locator()
235236
minor.formatter.set_locs(minorLocs)
236-
minorLabels = [minor.formatter(val, i) for i, val in enumerate(minorLocs)]
237+
minorLabels = [minor.formatter(val, i)
238+
for i, val in enumerate(minorLocs)]
237239

238240
trans_tick = self.get_tick_transform(axes)
239241

@@ -247,7 +249,9 @@ def _f(locs, labels):
247249

248250
# check if the tick point is inside axes
249251
c2 = tr2ax.transform_point(c)
250-
if 0 - self.delta1 <= c2[self.nth_coord] <= 1 + self.delta2:
252+
if (0 - self.delta1
253+
<= c2[self.nth_coord]
254+
<= 1 + self.delta2):
251255
yield c, angle_normal, angle_tangent, l
252256

253257
return _f(majorLocs, majorLabels), _f(minorLocs, minorLabels)
@@ -263,10 +267,9 @@ def get_line(self, axes):
263267
_verts = np.array([[0., 0.],
264268
[1., 1.]])
265269

266-
fixed_coord = 1-self.nth_coord
267-
trans_passingthrough_point = axes.transData + axes.transAxes.inverted()
268-
p = trans_passingthrough_point.transform_point([self._value,
269-
self._value])
270+
fixed_coord = 1 - self.nth_coord
271+
p = (axes.transData + axes.transAxes.inverted()).transform_point(
272+
[self._value, self._value])
270273
_verts[:, fixed_coord] = p[fixed_coord]
271274

272275
return Path(_verts)
@@ -297,9 +300,8 @@ def get_axislabel_pos_angle(self, axes):
297300
_verts = [0.5, 0.5]
298301

299302
fixed_coord = 1-self.nth_coord
300-
trans_passingthrough_point = axes.transData + axes.transAxes.inverted()
301-
p = trans_passingthrough_point.transform_point([self._value,
302-
self._value])
303+
p = (axes.transData + axes.transAxes.inverted()).transform_point(
304+
[self._value, self._value])
303305
_verts[fixed_coord] = p[fixed_coord]
304306
if not (0. <= _verts[fixed_coord] <= 1.):
305307
return None, None
@@ -329,12 +331,14 @@ def get_tick_iterators(self, axes):
329331
major = self.axis.major
330332
majorLocs = major.locator()
331333
major.formatter.set_locs(majorLocs)
332-
majorLabels = [major.formatter(val, i) for i, val in enumerate(majorLocs)]
334+
majorLabels = [major.formatter(val, i)
335+
for i, val in enumerate(majorLocs)]
333336

334337
minor = self.axis.minor
335338
minorLocs = minor.locator()
336339
minor.formatter.set_locs(minorLocs)
337-
minorLabels = [minor.formatter(val, i) for i, val in enumerate(minorLocs)]
340+
minorLabels = [minor.formatter(val, i)
341+
for i, val in enumerate(minorLocs)]
338342

339343
tr2ax = axes.transData + axes.transAxes.inverted()
340344

@@ -424,7 +428,8 @@ def new_fixed_axis(self, loc,
424428
):
425429

426430
if axes is None:
427-
warnings.warn("'new_fixed_axis' explicitly requires the axes keyword.")
431+
warnings.warn(
432+
"'new_fixed_axis' explicitly requires the axes keyword.")
428433
axes = self.axes
429434

430435
_helper = AxisArtistHelperRectlinear.Fixed(axes, loc, nth_coord)
@@ -615,12 +620,10 @@ def grid(self, b=None, which='major', axis="both", **kwargs):
615620
return
616621

617622
if b is None:
618-
619-
if self.axes.xaxis._gridOnMinor or self.axes.xaxis._gridOnMajor or \
620-
self.axes.yaxis._gridOnMinor or self.axes.yaxis._gridOnMajor:
621-
b=True
622-
else:
623-
b=False
623+
b = (self.axes.xaxis._gridOnMinor
624+
or self.axes.xaxis._gridOnMajor
625+
or self.axes.yaxis._gridOnMinor
626+
or self.axes.yaxis._gridOnMajor)
624627

625628
self.gridlines.set_which(which)
626629
self.gridlines.set_axis(axis)

0 commit comments

Comments
 (0)