Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitbfc0b5c

Browse files
committed
polar: Don't round all degree digits when zoomed.
1 parentca92216 commitbfc0b5c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

‎lib/matplotlib/projections/polar.py

Lines 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
ifrcParams['text.usetex']andnotrcParams['text.latex.unicode']:
178-
returnr"$%0.0f^\circ$"% ((x/np.pi)*180.0)
182+
format_str=r"$%%0.%df^\circ$"% (digits, )
183+
returnformat_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+
returnformat_str% ((x/np.pi)*180.0)
186192

187193

188194
classThetaLocator(MaxNLocator):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp