🌐 AI搜索 & 代理 主页
Skip to content

Commit 1977776

Browse files
committed
Only perturb padded tick marks for rectilinear axes
The function _get_pixel_distance_along_axis does not work for geographic axes, in which pixels that are outside of the map area cannot be meaningfully transformed back to data coordinates. To be safe, let us just return 0.0 unless we are on rectilinear axes. Fixes #2299.
1 parent c001797 commit 1977776

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/matplotlib/axis.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1657,7 +1657,7 @@ def _get_pixel_distance_along_axis(self, where, perturb):
16571657
# do things correctly, we need to use rmax instead of 1e-10 for a polar axis. But
16581658
# since we do not have that kind of information at this point, we just don't try to
16591659
# pad anything for the theta axis of a polar plot.
1660-
if self.axes.name == 'polar':
1660+
if self.axes.name != 'rectilinear':
16611661
return 0.0
16621662

16631663
#
@@ -1957,6 +1957,13 @@ def _get_pixel_distance_along_axis(self, where, perturb):
19571957
ticks are lost due to round-off at the extreme ends of an axis.
19581958
"""
19591959

1960+
# This routine does not work for geographic axes, in which pixels that
1961+
# are outside of the map area cannot be meaningfully transformed back
1962+
# to data coordinates. To be safe, let us just return 0.0 unless we
1963+
# are on rectilinear axes.
1964+
if self.axes.name != 'rectilinear':
1965+
return 0.0
1966+
19601967
#
19611968
# first figure out the pixel location of the "where" point. We use 1e-10 for the
19621969
# x point, so that we remain compatible with log axes.

0 commit comments

Comments
 (0)