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

Skip to content

Commit 7e608d4

Browse files
author
Daniel Hyams
committed
Pixel perturbation is now 0.5, for a more accurate calculation of exactly how
much padding to add.
1 parent 36ce184 commit 7e608d4

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

lib/matplotlib/axis.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -982,11 +982,11 @@ def _update_ticks(self, renderer):
982982

983983
if hasattr(self, '_get_pixel_distance_along_axis'):
984984
try:
985-
ds1 = self._get_pixel_distance_along_axis(interval_expanded[0], -1) / 2.0
985+
ds1 = self._get_pixel_distance_along_axis(interval_expanded[0], -0.5)
986986
except:
987987
ds1 = 0.0
988988
try:
989-
ds2 = self._get_pixel_distance_along_axis(interval_expanded[1], +1) / 2.0
989+
ds2 = self._get_pixel_distance_along_axis(interval_expanded[1], +0.5)
990990
except:
991991
ds2 = 0.0
992992
interval_expanded = (interval[0] - ds1, interval[1] + ds2)
@@ -1622,7 +1622,7 @@ 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.
1625-
"perturb" is the amount to perturb the pixel. Usually +1 or -1.
1625+
"perturb" is the amount to perturb the pixel. Usually +0.5 or -0.5.
16261626
16271627
Implementing this routine for an axis is optional; if present, it will ensure that no
16281628
ticks are lost due to round-off at the extreme ends of an axis.
@@ -1926,7 +1926,7 @@ def _get_pixel_distance_along_axis(self, where, perturb):
19261926
"""
19271927
Returns the amount, in data coordinates, that a single pixel corresponds to in the
19281928
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.
1929+
"perturb" is the amount to perturb the pixel. Usually +0.5 or -0.5.
19301930
19311931
Implementing this routine for an axis is optional; if present, it will ensure that no
19321932
ticks are lost due to round-off at the extreme ends of an axis.

0 commit comments

Comments
 (0)