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 1ffcd05

Browse filesBrowse files
committed
set_tick_params(label1On=False) should also make offset text invisible.
1 parent 3e6c5d0 commit 1ffcd05
Copy full SHA for 1ffcd05

File tree

Expand file treeCollapse file tree

3 files changed

+16
-1
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+16
-1
lines changed

‎doc/api/next_api_changes/behaviour.rst

Copy file name to clipboardExpand all lines: doc/api/next_api_changes/behaviour.rst
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,8 @@ Shortcuts for closing all figures now also work for the classic toolbar.
129129
There is no default shortcut any more because unintentionally closing all figures by a key press
130130
might happen too easily. You can configure the shortcut yourself
131131
using :rc:`keymap.quit_all`.
132+
133+
``set_tick_params(label1On=False)`` now also makes the offset text (if any) invisible
134+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
135+
... because the offset text can rarely be interpreted without tick labels
136+
anyways.

‎lib/matplotlib/axis.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axis.py
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,9 @@ def set_tick_params(self, which='major', reset=False, **kw):
823823
self._minor_tick_kw.update(kwtrans)
824824
for tick in self.minorTicks:
825825
tick._apply_params(**kwtrans)
826-
# special-case label color to also apply to the offset text
826+
# label1On and labelcolor also apply to the offset text.
827+
if 'label1On' in kwtrans:
828+
self.offsetText.set_visible(kwtrans['label1On'])
827829
if 'labelcolor' in kwtrans:
828830
self.offsetText.set_color(kwtrans['labelcolor'])
829831

‎lib/matplotlib/tests/test_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_axes.py
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5490,6 +5490,14 @@ def test_offset_label_color():
54905490
assert ax.yaxis.get_offset_text().get_color() == 'red'
54915491

54925492

5493+
def test_offset_text_visible():
5494+
fig = plt.figure()
5495+
ax = fig.add_subplot(1, 1, 1)
5496+
ax.plot([1.01e9, 1.02e9, 1.03e9])
5497+
ax.yaxis.set_tick_params(label1On=False)
5498+
assert not ax.yaxis.get_offset_text().get_visible()
5499+
5500+
54935501
def test_large_offset():
54945502
fig, ax = plt.subplots()
54955503
ax.plot((1 + np.array([0, 1.e-12])) * 1.e27)

0 commit comments

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