Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4674ad7

Browse files
committed
DOC spines example are now sphinx-gallery compliant
1 parent 3078330 commit 4674ad7

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

examples/ticks_and_spines/spines_demo.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
"""
2-
Basic demo of axis spines.
3-
4-
This demo compares a normal axes, with spines on all four sides, and an axes
5-
with spines only on the left and bottom.
2+
======
3+
Spines
4+
======
5+
6+
This demo compares :
7+
- normal axes, with spines on all four sides
8+
- an axes with spines only on the left and bottom.
9+
- an axes using custom bounds to limit the extent of the spine
610
"""
711
import numpy as np
812
import matplotlib.pyplot as plt
@@ -11,7 +15,7 @@
1115
x = np.linspace(0, 2 * np.pi, 100)
1216
y = 2 * np.sin(x)
1317

14-
fig, (ax0, ax1) = plt.subplots(nrows=2)
18+
fig, (ax0, ax1, ax2) = plt.subplots(nrows=3)
1519

1620
ax0.plot(x, y)
1721
ax0.set_title('normal spines')
@@ -26,7 +30,18 @@
2630
ax1.yaxis.set_ticks_position('left')
2731
ax1.xaxis.set_ticks_position('bottom')
2832

33+
34+
ax2.plot(x, y)
35+
36+
# Only draw spine between the y-ticks
37+
ax2.spines['left'].set_bounds(-1, 1)
38+
# Hide the right and top spines
39+
ax2.spines['right'].set_visible(False)
40+
ax2.spines['top'].set_visible(False)
41+
# Only show ticks on the left and bottom spines
42+
ax2.yaxis.set_ticks_position('left')
43+
ax2.xaxis.set_ticks_position('bottom')
44+
2945
# Tweak spacing between subplots to prevent labels from overlapping
3046
plt.subplots_adjust(hspace=0.5)
31-
3247
plt.show()

examples/ticks_and_spines/spines_demo_dropped.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
"""
2+
==============
3+
Dropped spines
4+
==============
5+
26
Demo of spines offset from the axes (a.k.a. "dropped spines").
37
"""
48
import numpy as np

0 commit comments

Comments
 (0)