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

Skip to content

Commit 36ce184

Browse files
author
Daniel Hyams
committed
More PEP8 fixes and comments
1 parent 43929de commit 36ce184

1 file changed

Lines changed: 23 additions & 12 deletions

File tree

lib/matplotlib/axis.py

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -980,7 +980,7 @@ def _update_ticks(self, renderer):
980980
else:
981981
interval_expanded = interval[1], interval[0]
982982

983-
if hasattr(self,'_get_pixel_distance_along_axis'):
983+
if hasattr(self, '_get_pixel_distance_along_axis'):
984984
try:
985985
ds1 = self._get_pixel_distance_along_axis(interval_expanded[0], -1) / 2.0
986986
except:
@@ -1618,11 +1618,14 @@ def _get_offset_text(self):
16181618
self.offset_text_position = 'bottom'
16191619
return offsetText
16201620

1621-
def _get_pixel_distance_along_axis(self,where,perturb):
1621+
def _get_pixel_distance_along_axis(self, where, perturb):
16221622
"""
16231623
Returns the amount, in data coordinates, that a single pixel corresponds to in the
16241624
locality given by "where", which is also given in data coordinates, and is an x coordinate.
16251625
"perturb" is the amount to perturb the pixel. Usually +1 or -1.
1626+
1627+
Implementing this routine for an axis is optional; if present, it will ensure that no
1628+
ticks are lost due to round-off at the extreme ends of an axis.
16261629
"""
16271630

16281631
# Note that this routine does not work for a polar axis, because of the 1e-10 below. To
@@ -1632,8 +1635,10 @@ def _get_pixel_distance_along_axis(self,where,perturb):
16321635
if self.axes.name == 'polar':
16331636
return 0.0
16341637

1635-
#first figure out the pixel location of the "where" point. We use 1e-10 for the
1636-
#y point, so that we remain compatible with log axes.
1638+
#
1639+
# first figure out the pixel location of the "where" point. We use 1e-10 for the
1640+
# y point, so that we remain compatible with log axes.
1641+
#
16371642
trans = self.axes.transData # transformation from data coords to display coords
16381643
transinv = trans.inverted() # transformation from display coords to data coords
16391644
pix = trans.transform_point((where, 1e-10))
@@ -1917,19 +1922,25 @@ def _get_offset_text(self):
19171922
self.offset_text_position = 'left'
19181923
return offsetText
19191924

1920-
def _get_pixel_distance_along_axis(self,where,perturb):
1921-
# returns the amount, in data coordinates, that a single pixel corresponds to in the
1922-
# locality given by "where", which is also given in data coordinates, and is a y coordinate.
1923-
# "perturb" is the amount to perturb the pixel. Usually +1 or -1.
1924-
1925+
def _get_pixel_distance_along_axis(self, where, perturb):
1926+
"""
1927+
Returns the amount, in data coordinates, that a single pixel corresponds to in the
1928+
locality given by "where", which is also given in data coordinates, and is an y coordinate.
1929+
"perturb" is the amount to perturb the pixel. Usually +1 or -1.
1930+
1931+
Implementing this routine for an axis is optional; if present, it will ensure that no
1932+
ticks are lost due to round-off at the extreme ends of an axis.
1933+
"""
1934+
1935+
#
19251936
# first figure out the pixel location of the "where" point. We use 1e-10 for the
19261937
# x point, so that we remain compatible with log axes.
19271938
#
19281939
trans = self.axes.transData # transformation from data coords to display coords
19291940
transinv = trans.inverted() # transformation from display coords to data coords
1930-
pix = trans.transform_point((1e-10,where))
1931-
ptp = transinv.transform_point((pix[0],pix[1]+perturb)) # perturb the pixel.
1932-
dy = abs(ptp[1]-where)
1941+
pix = trans.transform_point((1e-10, where))
1942+
ptp = transinv.transform_point((pix[0], pix[1] + perturb)) # perturb the pixel.
1943+
dy = abs(ptp[1] - where)
19331944
return dy
19341945

19351946
def get_label_position(self):

0 commit comments

Comments
 (0)