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 bfc0b5c

Browse filesBrowse files
committed
polar: Don't round all degree digits when zoomed.
1 parent ca92216 commit bfc0b5c
Copy full SHA for bfc0b5c

File tree

Expand file treeCollapse file tree

1 file changed

+8
-2
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+8
-2
lines changed

‎lib/matplotlib/projections/polar.py

Copy file name to clipboardExpand all lines: lib/matplotlib/projections/polar.py
+8-2Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,16 +173,22 @@ class ThetaFormatter(Formatter):
173173
unit of radians into degrees and adds a degree symbol.
174174
"""
175175
def __call__(self, x, pos=None):
176+
vmin, vmax = self.axis.get_view_interval()
177+
d = abs(vmax - vmin) / np.pi * 180.0
178+
digits = max(-int(np.log10(d) - 1.5), 0)
179+
176180
# \u00b0 : degree symbol
177181
if rcParams['text.usetex'] and not rcParams['text.latex.unicode']:
178-
return r"$%0.0f^\circ$" % ((x / np.pi) * 180.0)
182+
format_str = r"$%%0.%df^\circ$" % (digits, )
183+
return format_str % ((x / np.pi) * 180.0)
179184
else:
180185
# we use unicode, rather than mathtext with \circ, so
181186
# that it will work correctly with any arbitrary font
182187
# (assuming it has a degree sign), whereas $5\circ$
183188
# will only work correctly with one of the supported
184189
# math fonts (Computer Modern and STIX)
185-
return "%0.0f\u00b0" % ((x / np.pi) * 180.0)
190+
format_str = "%%0.%df\u00b0" % (digits, )
191+
return format_str % ((x / np.pi) * 180.0)
186192

187193

188194
class ThetaLocator(MaxNLocator):

0 commit comments

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