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

Skip to content

Commit 2ac8e47

Browse files
committed
Reduce the floating point slop allowance in selecting ticks to show.
In #1686 this was set to half a pixel, but I don't think this makes sense, and it is not needed in order to pass the test that was added to check for lost ticks (#1310), or for the cases in #1310.
1 parent 7c0e760 commit 2ac8e47

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

lib/matplotlib/axis.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,9 +1053,7 @@ def _update_ticks(self, renderer):
10531053
tick_tups = [ti for ti in tick_tups if ilow <= ti[1] <= ihigh]
10541054

10551055
# so that we don't lose ticks on the end, expand out the interval ever
1056-
# so slightly. The "ever so slightly" is defined to be the width of a
1057-
# half of a pixel. We don't want to draw a tick that even one pixel
1058-
# outside of the defined axis interval.
1056+
# so slightly to compensate for floating point slop.
10591057
if interval[0] <= interval[1]:
10601058
interval_expanded = interval
10611059
else:
@@ -1076,8 +1074,8 @@ def _update_ticks(self, renderer):
10761074
with np.errstate(invalid='ignore'):
10771075
try:
10781076
ds1 = self._get_pixel_distance_along_axis(
1079-
interval_expanded[0], -0.5)
1080-
except Exception:
1077+
interval_expanded[0], -0.0005)
1078+
except:
10811079
warnings.warn("Unable to find pixel distance along axis "
10821080
"for interval padding of ticks; assuming no "
10831081
"interval padding needed.")
@@ -1086,8 +1084,8 @@ def _update_ticks(self, renderer):
10861084
ds1 = 0.0
10871085
try:
10881086
ds2 = self._get_pixel_distance_along_axis(
1089-
interval_expanded[1], +0.5)
1090-
except Exception:
1087+
interval_expanded[1], +0.0005)
1088+
except:
10911089
warnings.warn("Unable to find pixel distance along axis "
10921090
"for interval padding of ticks; assuming no "
10931091
"interval padding needed.")

0 commit comments

Comments
 (0)