Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9661a02

Browse filesBrowse files
committed
Merge pull request #3282 from jenshnielsen/mollweide_warning
Catch warning thrown in Mollweide projection.
2 parents 9d648fc + ffe211e commit 9661a02
Copy full SHA for 9661a02

File tree

Expand file treeCollapse file tree

1 file changed

+25
-14
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+25
-14
lines changed

‎lib/matplotlib/axis.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axis.py
+25-14Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,20 +1010,31 @@ def _update_ticks(self, renderer):
10101010
# the idea that one would rather potentially lose a tick
10111011
# from one side of the axis or another, rather than see a
10121012
# stack trace.
1013-
try:
1014-
ds1 = self._get_pixel_distance_along_axis(interval_expanded[0], -0.5)
1015-
except:
1016-
warnings.warn("Unable to find pixel distance along axis for interval padding; assuming no interval padding needed.")
1017-
ds1 = 0.0
1018-
if np.isnan(ds1):
1019-
ds1 = 0.0
1020-
try:
1021-
ds2 = self._get_pixel_distance_along_axis(interval_expanded[1], +0.5)
1022-
except:
1023-
warnings.warn("Unable to find pixel distance along axis for interval padding; assuming no interval padding needed.")
1024-
ds2 = 0.0
1025-
if np.isnan(ds2):
1026-
ds2 = 0.0
1013+
# We also catch users warnings here. These are the result of
1014+
# invalid numpy calculations that may be the result of out of
1015+
# bounds on axis with finite allowed intervals such as geo
1016+
# projections i.e. Mollweide.
1017+
with np.errstate(invalid='ignore'):
1018+
try:
1019+
ds1 = self._get_pixel_distance_along_axis(
1020+
interval_expanded[0], -0.5)
1021+
except:
1022+
warnings.warn("Unable to find pixel distance along axis for\
1023+
interval padding of ticks; assuming no interval padding\
1024+
needed.")
1025+
ds1 = 0.0
1026+
if np.isnan(ds1):
1027+
ds1 = 0.0
1028+
try:
1029+
ds2 = self._get_pixel_distance_along_axis(
1030+
interval_expanded[1], +0.5)
1031+
except:
1032+
warnings.warn("Unable to find pixel distance along axis for\
1033+
interval padding of ticks; assuming no interval padding\
1034+
needed.")
1035+
ds2 = 0.0
1036+
if np.isnan(ds2):
1037+
ds2 = 0.0
10271038
interval_expanded = (interval_expanded[0] - ds1,
10281039
interval_expanded[1] + ds2)
10291040

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.