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 54abca4

Browse filesBrowse files
committed
TST: Added test to check that axis labels are located correctly when no tick labels are present and axis spines are offset (see issue #3715)
1 parent ebb2e63 commit 54abca4
Copy full SHA for 54abca4

File tree

Expand file treeCollapse file tree

1 file changed

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

1 file changed

+36
-2
lines changed

‎lib/matplotlib/tests/test_spines.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_spines.py
+36-2Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
from __future__ import (absolute_import, division, print_function,
22
unicode_literals)
33

4+
import numpy as np
5+
from nose.tools import assert_less
46
import six
57

6-
import numpy as np
78
import matplotlib
8-
from matplotlib.testing.decorators import image_comparison
99
import matplotlib.pyplot as plt
10+
import matplotlib.transforms as mtransforms
11+
from matplotlib.testing.decorators import image_comparison, cleanup
12+
1013

1114
@image_comparison(baseline_images=['spines_axes_positions'])
1215
def test_spines_axes_positions():
@@ -43,3 +46,34 @@ def test_spines_capstyle():
4346
ax = fig.add_subplot(1,1,1)
4447
ax.set_xticks([])
4548
ax.set_yticks([])
49+
50+
51+
@cleanup
52+
def test_label_without_ticks():
53+
fig = plt.figure()
54+
ax = fig.add_subplot(1, 1, 1)
55+
plt.subplots_adjust(left=0.3, bottom=0.3)
56+
ax.plot(np.arange(10))
57+
ax.yaxis.set_ticks_position('left')
58+
ax.spines['left'].set_position(('outward', 30))
59+
ax.spines['right'].set_visible(False)
60+
ax.set_ylabel('y label')
61+
ax.xaxis.set_ticks_position('bottom')
62+
ax.spines['bottom'].set_position(('outward', 30))
63+
ax.spines['top'].set_visible(False)
64+
ax.set_xlabel('x label')
65+
ax.xaxis.set_ticks([])
66+
ax.yaxis.set_ticks([])
67+
plt.draw()
68+
69+
spine = ax.spines['left']
70+
spinebbox = spine.get_transform().transform_path(
71+
spine.get_path()).get_extents()
72+
assert_less(ax.yaxis.label.get_position()[0], spinebbox.xmin,
73+
"Y-Axis label not left of the spine")
74+
75+
spine = ax.spines['bottom']
76+
spinebbox = spine.get_transform().transform_path(
77+
spine.get_path()).get_extents()
78+
assert_less(ax.xaxis.label.get_position()[1], spinebbox.ymin,
79+
"X-Axis label not below the spine")

0 commit comments

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