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

Skip to content

Commit 34970ed

Browse files
timhoffmImportanceOfBeingErnest
authored andcommitted
Remove axes border for examples that list styles (#13683)
1 parent e4cc98b commit 34970ed

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

examples/lines_bars_and_markers/joinstyle.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ def plot_angle(ax, x, y, angle, style):
4747

4848
ax.set_xlim(-1.5, 2.75)
4949
ax.set_ylim(-.5, 5.5)
50-
ax.xaxis.set_visible(False)
51-
ax.yaxis.set_visible(False)
50+
ax.set_axis_off()
5251
plt.show()
5352

5453

@@ -66,17 +65,16 @@ def plot_angle(ax, x, y, angle, style):
6665
ax.set_title('Cap style')
6766

6867
for x, style in enumerate(['butt', 'round', 'projecting']):
69-
ax.text(x, 1, style)
68+
ax.text(x+0.25, 1, style, ha='center')
7069
xx = [x, x+0.5]
7170
yy = [0, 0]
7271
ax.plot(xx, yy, lw=12, color='tab:blue', solid_capstyle=style)
7372
ax.plot(xx, yy, lw=1, color='black')
7473
ax.plot(xx, yy, 'o', color='tab:red', markersize=3)
75-
ax.text(2, 0.7, '(default)')
74+
ax.text(2.25, 0.7, '(default)', ha='center')
7675

7776
ax.set_ylim(-.5, 1.5)
78-
ax.xaxis.set_visible(False)
79-
ax.yaxis.set_visible(False)
77+
ax.set_axis_off()
8078

8179

8280
#############################################################################

examples/lines_bars_and_markers/linestyles.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,21 @@
4141
('densely dashdotdotted', (0, (3, 1, 1, 1, 1, 1)))]
4242

4343

44-
def plot_linestyles(ax, linestyles):
44+
def plot_linestyles(ax, linestyles, title):
4545
X, Y = np.linspace(0, 100, 10), np.zeros(10)
4646
yticklabels = []
4747

4848
for i, (name, linestyle) in enumerate(linestyles):
4949
ax.plot(X, Y+i, linestyle=linestyle, linewidth=1.5, color='black')
5050
yticklabels.append(name)
5151

52-
ax.set(xticks=[], ylim=(-0.5, len(linestyles)-0.5),
53-
yticks=np.arange(len(linestyles)), yticklabels=yticklabels)
52+
ax.set_title(title)
53+
ax.set(ylim=(-0.5, len(linestyles)-0.5),
54+
yticks=np.arange(len(linestyles)),
55+
yticklabels=yticklabels)
56+
ax.tick_params(left=False, bottom=False, labelbottom=False)
57+
for spine in ax.spines.values():
58+
spine.set_visible(False)
5459

5560
# For each line style, add a text annotation with a small offset from
5661
# the reference point (0 in Axes coords, y tick value in Data coords).
@@ -64,8 +69,8 @@ def plot_linestyles(ax, linestyles):
6469
fig, (ax0, ax1) = plt.subplots(2, 1, gridspec_kw={'height_ratios': [1, 3]},
6570
figsize=(10, 8))
6671

67-
plot_linestyles(ax0, linestyle_str[::-1])
68-
plot_linestyles(ax1, linestyle_tuple[::-1])
72+
plot_linestyles(ax0, linestyle_str[::-1], title='Named linestyles')
73+
plot_linestyles(ax1, linestyle_tuple[::-1], title='Parametrized linestyles')
6974

7075
plt.tight_layout()
7176
plt.show()

0 commit comments

Comments
 (0)