Skip to content

Commit bdb9302

Browse files
committed
Use new Spines API throughout the library
1 parent 2b08562 commit bdb9302

File tree

26 files changed

+107
-121
lines changed

26 files changed

+107
-121
lines changed

examples/axes_grid1/demo_axes_rgb.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ def demo_rgb2():
6060

6161
for ax in fig.axes:
6262
ax.tick_params(axis='both', direction='in')
63-
for sp1 in ax.spines.values():
64-
sp1.set_color("w")
63+
ax.spines.all.set_color("w")
6564
for tick in ax.xaxis.get_major_ticks() + ax.yaxis.get_major_ticks():
6665
tick.tick1line.set_markeredgecolor("w")
6766
tick.tick2line.set_markeredgecolor("w")

examples/images_contours_and_fields/image_annotated_heatmap.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,7 @@ def heatmap(data, row_labels, col_labels, ax=None,
149149
rotation_mode="anchor")
150150

151151
# Turn spines off and create white grid.
152-
for edge, spine in ax.spines.items():
153-
spine.set_visible(False)
152+
ax.spines.all.set_visible(False)
154153

155154
ax.set_xticks(np.arange(data.shape[1]+1)-.5, minor=True)
156155
ax.set_yticks(np.arange(data.shape[0]+1)-.5, minor=True)

examples/lines_bars_and_markers/linestyles.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ def plot_linestyles(ax, linestyles, title):
5454
yticks=np.arange(len(linestyles)),
5555
yticklabels=yticklabels)
5656
ax.tick_params(left=False, bottom=False, labelbottom=False)
57-
for spine in ax.spines.values():
58-
spine.set_visible(False)
57+
ax.spines.all.set_visible(False)
5958

6059
# For each line style, add a text annotation with a small offset from
6160
# the reference point (0 in Axes coords, y tick value in Data coords).

examples/showcase/bachelors_degrees_by_gender.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@
3232
'#17becf', '#9edae5'])
3333

3434
# Remove the plot frame lines. They are unnecessary here.
35-
ax.spines['top'].set_visible(False)
36-
ax.spines['bottom'].set_visible(False)
37-
ax.spines['right'].set_visible(False)
38-
ax.spines['left'].set_visible(False)
35+
ax.spines.all.set_visible(False)
3936

4037
# Ensure that the axis ticks only show up on the bottom and left of the plot.
4138
# Ticks on the right and top of the plot are generally unnecessary.

examples/showcase/integral.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ def func(x):
4242
fig.text(0.9, 0.05, '$x$')
4343
fig.text(0.1, 0.9, '$y$')
4444

45-
ax.spines['right'].set_visible(False)
46-
ax.spines['top'].set_visible(False)
45+
ax.spines.right.set_visible(False)
46+
ax.spines.top.set_visible(False)
4747
ax.xaxis.set_ticks_position('bottom')
4848

4949
ax.set_xticks((a, b))

examples/showcase/xkcd.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
fig = plt.figure()
1818
ax = fig.add_axes((0.1, 0.2, 0.8, 0.7))
19-
ax.spines['right'].set_color('none')
20-
ax.spines['top'].set_color('none')
19+
ax.spines.right.set_color('none')
20+
ax.spines.top.set_color('none')
2121
ax.set_xticks([])
2222
ax.set_yticks([])
2323
ax.set_ylim([-30, 10])
@@ -47,8 +47,8 @@
4747
fig = plt.figure()
4848
ax = fig.add_axes((0.1, 0.2, 0.8, 0.7))
4949
ax.bar([0, 1], [0, 100], 0.25)
50-
ax.spines['right'].set_color('none')
51-
ax.spines['top'].set_color('none')
50+
ax.spines.right.set_color('none')
51+
ax.spines.top.set_color('none')
5252
ax.xaxis.set_ticks_position('bottom')
5353
ax.set_xticks([0, 1])
5454
ax.set_xticklabels(['CONFIRMED BY\nEXPERIMENT', 'REFUTED BY\nEXPERIMENT'])

examples/specialty_plots/skewt.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ class SkewXAxes(Axes):
8686
def _init_axis(self):
8787
# Taken from Axes and modified to use our modified X-axis
8888
self.xaxis = SkewXAxis(self)
89-
self.spines['top'].register_axis(self.xaxis)
90-
self.spines['bottom'].register_axis(self.xaxis)
89+
self.spines.top.register_axis(self.xaxis)
90+
self.spines.bottom.register_axis(self.xaxis)
9191
self.yaxis = maxis.YAxis(self)
92-
self.spines['left'].register_axis(self.yaxis)
93-
self.spines['right'].register_axis(self.yaxis)
92+
self.spines.left.register_axis(self.yaxis)
93+
self.spines.right.register_axis(self.yaxis)
9494

9595
def _gen_axes_spines(self):
9696
spines = {'top': SkewSpine.linear_spine(self, 'top'),

examples/subplots_axes_and_figures/broken_axis.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
ax2.set_ylim(0, .22) # most of the data
3232

3333
# hide the spines between ax and ax2
34-
ax1.spines['bottom'].set_visible(False)
35-
ax2.spines['top'].set_visible(False)
34+
ax1.spines.bottom.set_visible(False)
35+
ax2.spines.top.set_visible(False)
3636
ax1.xaxis.tick_top()
3737
ax1.tick_params(labeltop=False) # don't put tick labels at the top
3838
ax2.xaxis.tick_bottom()

examples/ticks_and_spines/multiple_yaxis_with_spines.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
def make_patch_spines_invisible(ax):
1919
ax.set_frame_on(True)
2020
ax.patch.set_visible(False)
21-
for sp in ax.spines.values():
22-
sp.set_visible(False)
21+
ax.spines.all.set_visible(False)
2322

2423

2524
fig, host = plt.subplots()
@@ -30,13 +29,13 @@ def make_patch_spines_invisible(ax):
3029

3130
# Offset the right spine of par2. The ticks and label have already been
3231
# placed on the right by twinx above.
33-
par2.spines["right"].set_position(("axes", 1.2))
32+
par2.spines.right.set_position(("axes", 1.2))
3433
# Having been created by twinx, par2 has its frame off, so the line of its
3534
# detached spine is invisible. First, activate the frame but make the patch
3635
# and spines invisible.
3736
make_patch_spines_invisible(par2)
3837
# Second, show the right spine.
39-
par2.spines["right"].set_visible(True)
38+
par2.spines.right.set_visible(True)
4039

4140
p1, = host.plot([0, 1, 2], [0, 1, 2], "b-", label="Density")
4241
p2, = par1.plot([0, 1, 2], [0, 3, 2], "r-", label="Temperature")

examples/ticks_and_spines/spine_placement_demo.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,40 +18,40 @@
1818
ax = fig.add_subplot(2, 2, 1)
1919
ax.set_title('centered spines')
2020
ax.plot(x, y)
21-
ax.spines['left'].set_position('center')
22-
ax.spines['right'].set_color('none')
23-
ax.spines['bottom'].set_position('center')
24-
ax.spines['top'].set_color('none')
21+
ax.spines.left.set_position('center')
22+
ax.spines.right.set_color('none')
23+
ax.spines.bottom.set_position('center')
24+
ax.spines.top.set_color('none')
2525
ax.xaxis.set_ticks_position('bottom')
2626
ax.yaxis.set_ticks_position('left')
2727

2828
ax = fig.add_subplot(2, 2, 2)
2929
ax.set_title('zeroed spines')
3030
ax.plot(x, y)
31-
ax.spines['left'].set_position('zero')
32-
ax.spines['right'].set_color('none')
33-
ax.spines['bottom'].set_position('zero')
34-
ax.spines['top'].set_color('none')
31+
ax.spines.left.set_position('zero')
32+
ax.spines.right.set_color('none')
33+
ax.spines.bottom.set_position('zero')
34+
ax.spines.top.set_color('none')
3535
ax.xaxis.set_ticks_position('bottom')
3636
ax.yaxis.set_ticks_position('left')
3737

3838
ax = fig.add_subplot(2, 2, 3)
3939
ax.set_title('spines at axes (0.6, 0.1)')
4040
ax.plot(x, y)
41-
ax.spines['left'].set_position(('axes', 0.6))
42-
ax.spines['right'].set_color('none')
43-
ax.spines['bottom'].set_position(('axes', 0.1))
44-
ax.spines['top'].set_color('none')
41+
ax.spines.left.set_position(('axes', 0.6))
42+
ax.spines.right.set_color('none')
43+
ax.spines.bottom.set_position(('axes', 0.1))
44+
ax.spines.top.set_color('none')
4545
ax.xaxis.set_ticks_position('bottom')
4646
ax.yaxis.set_ticks_position('left')
4747

4848
ax = fig.add_subplot(2, 2, 4)
4949
ax.set_title('spines at data (1, 2)')
5050
ax.plot(x, y)
51-
ax.spines['left'].set_position(('data', 1))
52-
ax.spines['right'].set_color('none')
53-
ax.spines['bottom'].set_position(('data', 2))
54-
ax.spines['top'].set_color('none')
51+
ax.spines.left.set_position(('data', 1))
52+
ax.spines.right.set_color('none')
53+
ax.spines.bottom.set_position(('data', 2))
54+
ax.spines.top.set_color('none')
5555
ax.xaxis.set_ticks_position('bottom')
5656
ax.yaxis.set_ticks_position('left')
5757

0 commit comments

Comments
 (0)