From 00844f98ccda9c1db2ced3755a49d1d3f81e30a9 Mon Sep 17 00:00:00 2001 From: Eric Wieser Date: Fri, 19 Oct 2018 22:04:49 -0700 Subject: [PATCH] BUG: mplot3d: Don't crash if azim or elev are non-integral Formatting these via a format string causes 'inf' or 'nan' to be displayed in the status bar, which is much better than crashing because the user tried to rotate. --- lib/mpl_toolkits/mplot3d/axes3d.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/mpl_toolkits/mplot3d/axes3d.py b/lib/mpl_toolkits/mplot3d/axes3d.py index 0a8103287110..c72ebde234e9 100644 --- a/lib/mpl_toolkits/mplot3d/axes3d.py +++ b/lib/mpl_toolkits/mplot3d/axes3d.py @@ -1169,7 +1169,8 @@ def format_coord(self, xd, yd): return '' if self.button_pressed in self._rotate_btn: - return 'azimuth=%d deg, elevation=%d deg ' % (self.azim, self.elev) + return 'azimuth={:.0f} deg, elevation={:.0f} deg '.format( + self.azim, self.elev) # ignore xd and yd and display angles instead # nearest edge