|
1 | 1 | from __future__ import (absolute_import, division, print_function,
|
2 | 2 | unicode_literals)
|
3 | 3 |
|
| 4 | +import numpy as np |
| 5 | +from nose.tools import assert_less |
4 | 6 | import six
|
5 | 7 |
|
6 |
| -import numpy as np |
7 | 8 | import matplotlib
|
8 |
| -from matplotlib.testing.decorators import image_comparison |
9 | 9 | import matplotlib.pyplot as plt
|
| 10 | +import matplotlib.transforms as mtransforms |
| 11 | +from matplotlib.testing.decorators import image_comparison, cleanup |
| 12 | + |
10 | 13 |
|
11 | 14 | @image_comparison(baseline_images=['spines_axes_positions'])
|
12 | 15 | def test_spines_axes_positions():
|
@@ -43,3 +46,34 @@ def test_spines_capstyle():
|
43 | 46 | ax = fig.add_subplot(1,1,1)
|
44 | 47 | ax.set_xticks([])
|
45 | 48 | 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