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 255d4c3

Browse filesBrowse files
committed
add axes.formatter.offset_threshold rcParam: classic is 2, v2.0 is 4
1 parent daa5ed6 commit 255d4c3
Copy full SHA for 255d4c3

File tree

Expand file treeCollapse file tree

5 files changed

+15
-5
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+15
-5
lines changed

‎lib/matplotlib/mpl-data/stylelib/classic.mplstyle

Copy file name to clipboardExpand all lines: lib/matplotlib/mpl-data/stylelib/classic.mplstyle
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,10 @@ axes.formatter.useoffset : True # If True, the tick label formatter
204204
# to an offset when the data range is very
205205
# small compared to the minimum absolute
206206
# value of the data.
207+
axes.formatter.offset_threshold : 2 # When useoffset is True, the offset
208+
# will be used when it can remove
209+
# at least this number of significant
210+
# digits from tick labels.
207211

208212
axes.unicode_minus : True # use unicode for the minus symbol
209213
# rather than hyphen. See

‎lib/matplotlib/rcsetup.py

Copy file name to clipboardExpand all lines: lib/matplotlib/rcsetup.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,6 +1085,7 @@ def validate_animation_writer_path(p):
10851085
# Use the current locale to format ticks
10861086
'axes.formatter.use_mathtext': [False, validate_bool],
10871087
'axes.formatter.useoffset': [True, validate_bool],
1088+
'axes.formatter.offset_threshold': [4, validate_int],
10881089
'axes.unicode_minus': [True, validate_bool],
10891090
'axes.color_cycle': [
10901091
['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728',

‎lib/matplotlib/tests/test_ticker.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_ticker.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def test_SymmetricalLogLocator_set_params():
169169
nose.tools.assert_equal(sym.numticks, 8)
170170

171171

172-
@cleanup
172+
@cleanup(style='classic')
173173
def test_ScalarFormatter_offset_value():
174174
fig, ax = plt.subplots()
175175
formatter = ax.get_xaxis().get_major_formatter()

‎lib/matplotlib/ticker.py

Copy file name to clipboardExpand all lines: lib/matplotlib/ticker.py
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,7 @@ def __init__(self, useOffset=None, useMathText=None, useLocale=None):
505505

506506
if useOffset is None:
507507
useOffset = rcParams['axes.formatter.useoffset']
508+
self._offset_threshold = rcParams['axes.formatter.offset_threshold']
508509
self.set_useOffset(useOffset)
509510
self._usetex = rcParams['text.usetex']
510511
if useMathText is None:
@@ -689,9 +690,10 @@ def _compute_offset(self):
689690
# are no more than 1 apart at that precision?
690691
oom = 1 + next(oom for oom in itertools.count(oom_max, -1)
691692
if abs_max // 10 ** oom - abs_min // 10 ** oom > 1)
692-
# Only use offset if it saves at least 4 significant digits.
693+
# Only use offset if it saves at least _offset_threshold digits.
694+
n = self._offset_threshold - 1
693695
self.offset = (sign * (abs_max // 10 ** oom) * 10 ** oom
694-
if abs_max // 10 ** oom >= 10**3 # 10**(4-1)
696+
if abs_max // 10 ** oom >= 10**n
695697
else 0)
696698

697699
def _set_orderOfMagnitude(self, range):

‎matplotlibrc.template

Copy file name to clipboardExpand all lines: matplotlibrc.template
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,13 @@ backend : $TEMPLATE_BACKEND
317317
# notation.
318318
#axes.formatter.useoffset : True # If True, the tick label formatter
319319
# will default to labeling ticks relative
320-
# to an offset when the data range is very
320+
# to an offset when the data range is
321321
# small compared to the minimum absolute
322322
# value of the data.
323-
323+
#axes.formatter.offset_threshold : 4 # When useoffset is True, the offset
324+
# will be used when it can remove
325+
# at least this number of significant
326+
# digits from tick labels.
324327

325328
#axes.unicode_minus : True # use unicode for the minus symbol
326329
# rather than hyphen. See

0 commit comments

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