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

Skip to content

Commit efdf987

Browse files
committed
Assume pixel distance=0 if nan
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. If the return value was nan, set to 0.
1 parent 3165537 commit efdf987

File tree

5 files changed

+1866
-0
lines changed

5 files changed

+1866
-0
lines changed

lib/matplotlib/axis.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,11 +1008,15 @@ def _update_ticks(self, renderer):
10081008
except:
10091009
warnings.warn("Unable to find pixel distance along axis for interval padding; assuming no interval padding needed.")
10101010
ds1 = 0.0
1011+
if np.isnan(ds1):
1012+
ds1 = 0.0
10111013
try:
10121014
ds2 = self._get_pixel_distance_along_axis(interval_expanded[1], +0.5)
10131015
except:
10141016
warnings.warn("Unable to find pixel distance along axis for interval padding; assuming no interval padding needed.")
10151017
ds2 = 0.0
1018+
if np.isnan(ds2):
1019+
ds2 = 0.0
10161020
interval_expanded = (interval_expanded[0] - ds1,
10171021
interval_expanded[1] + ds2)
10181022

Binary file not shown.

0 commit comments

Comments
 (0)