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

Commit757fb24

Browse files
authored
Merge pull request#16786 from anntzer/fmtclean
Simple cleanups to formatters.
2 parents71163e9 +6d322d4 commit757fb24

File tree

1 file changed

+7
-22
lines changed

1 file changed

+7
-22
lines changed

‎lib/matplotlib/ticker.py

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -834,8 +834,8 @@ class LogFormatter(Formatter):
834834
835835
To label all minor ticks when the view limits span up to 1.5
836836
decades, use ``minor_thresholds=(1.5, 1.5)``.
837-
838837
"""
838+
839839
def__init__(self,base=10.0,labelOnlyBase=False,
840840
minor_thresholds=None,
841841
linthresh=None):
@@ -857,7 +857,6 @@ def base(self, base):
857857
858858
.. warning::
859859
Should always match the base used for :class:`LogLocator`
860-
861860
"""
862861
self._base=base
863862

@@ -869,7 +868,6 @@ def label_minor(self, labelOnlyBase):
869868
----------
870869
labelOnlyBase : bool
871870
If True, label ticks only at integer powers of base.
872-
873871
"""
874872
self.labelOnlyBase=labelOnlyBase
875873

@@ -878,7 +876,6 @@ def set_locs(self, locs=None):
878876
Use axis view limits to control which ticks are labeled.
879877
880878
The *locs* parameter is ignored in the present algorithm.
881-
882879
"""
883880
ifnp.isinf(self.minor_thresholds[0]):
884881
self._sublabels=None
@@ -943,9 +940,7 @@ def _num_to_string(self, x, vmin, vmax):
943940
returns
944941

945942
def__call__(self,x,pos=None):
946-
"""
947-
Return the format for tick val *x*.
948-
"""
943+
# docstring inherited
949944
ifx==0.0:# Symlog
950945
return'0'
951946

@@ -968,11 +963,8 @@ def __call__(self, x, pos=None):
968963
returns
969964

970965
defformat_data(self,value):
971-
b=self.labelOnlyBase
972-
self.labelOnlyBase=False
973-
value=cbook.strip_math(self.__call__(value))
974-
self.labelOnlyBase=b
975-
returnvalue
966+
withcbook._setattr_cm(self,labelOnlyBase=False):
967+
returncbook.strip_math(self.__call__(value))
976968

977969
defformat_data_short(self,value):
978970
# docstring inherited
@@ -1027,11 +1019,7 @@ def _non_decade_format(self, sign_string, base, fx, usetex):
10271019
returnr'$\mathdefault{%s%s^{%.2f}}$'% (sign_string,base,fx)
10281020

10291021
def__call__(self,x,pos=None):
1030-
"""
1031-
Return the format for tick value *x*.
1032-
1033-
The position *pos* is ignored.
1034-
"""
1022+
# docstring inherited
10351023
usetex=mpl.rcParams['text.usetex']
10361024
min_exp=mpl.rcParams['axes.formatter.min_exponent']
10371025

@@ -1271,11 +1259,8 @@ def __call__(self, x, pos=None):
12711259
returnr"$\mathdefault{%s}$"%s
12721260

12731261
defformat_data_short(self,value):
1274-
"""
1275-
Return a short formatted string representation of a number.
1276-
"""
1277-
# thresholds choosen for use scienfic notation if and only if exponent
1278-
# is less or equal than -2.
1262+
# docstring inherited
1263+
# Thresholds chosen to use scientific notation iff exponent <= -2.
12791264
ifvalue<0.1:
12801265
return"{:e}".format(value)
12811266
ifvalue<0.9:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp