Skip to content

Commit fe0c692

Browse files
committed
Use new Spines API throughout the library
1 parent dc160d8 commit fe0c692

28 files changed

Lines changed: 110 additions & 128 deletions

‎examples/axes_grid1/demo_axes_rgb.py‎

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

5959
for ax in fig.axes:
6060
ax.tick_params(axis='both', direction='in')
61-
for sp1 in ax.spines.values():
62-
sp1.set_color("w")
61+
ax.spines[:].set_color("w")
6362
for tick in ax.xaxis.get_major_ticks() + ax.yaxis.get_major_ticks():
6463
tick.tick1line.set_markeredgecolor("w")
6564
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[:].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[:].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/lines_bars_and_markers/timeline.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@
8989

9090
# remove y axis and spines
9191
ax.yaxis.set_visible(False)
92-
for spine in ["left", "top", "right"]:
93-
ax.spines[spine].set_visible(False)
92+
ax.spines[["left", "top", "right"]].set_visible(False)
9493

9594
ax.margins(y=0.1)
9695
plt.show()

‎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[:].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
@@ -85,11 +85,11 @@ class SkewXAxes(Axes):
8585
def _init_axis(self):
8686
# Taken from Axes and modified to use our modified X-axis
8787
self.xaxis = SkewXAxis(self)
88-
self.spines['top'].register_axis(self.xaxis)
89-
self.spines['bottom'].register_axis(self.xaxis)
88+
self.spines.top.register_axis(self.xaxis)
89+
self.spines.bottom.register_axis(self.xaxis)
9090
self.yaxis = maxis.YAxis(self)
91-
self.spines['left'].register_axis(self.yaxis)
92-
self.spines['right'].register_axis(self.yaxis)
91+
self.spines.left.register_axis(self.yaxis)
92+
self.spines.right.register_axis(self.yaxis)
9393

9494
def _gen_axes_spines(self):
9595
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/centered_spines_with_arrows.py‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@
1414

1515
fig, ax = plt.subplots()
1616
# Move the left and bottom spines to x = 0 and y = 0, respectively.
17-
ax.spines["left"].set_position(("data", 0))
18-
ax.spines["bottom"].set_position(("data", 0))
17+
ax.spines[["left", "bottom"]].set_position(("data", 0))
1918
# Hide the top and right spines.
20-
ax.spines["top"].set_visible(False)
21-
ax.spines["right"].set_visible(False)
19+
ax.spines[["top", "right"]].set_visible(False)
2220

2321
# Draw arrows (as black triangles: ">k"/"^k") at the end of the axes. In each
2422
# case, one of the coordinates (0) is a data coordinate (i.e., y = 0 or x = 0,

0 commit comments

Comments
 (0)