Skip to content

Commit 97afb7f

Browse files
committed
Tweak subplot layout to prevent label clipping
1 parent 12cbf1a commit 97afb7f

File tree

4 files changed

+9
-1
lines changed

4 files changed

+9
-1
lines changed

examples/statistics/histogram_demo_features.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,6 @@
3030
plt.ylabel('Probability')
3131
plt.title(r'Histogram of IQ: $\mu=100$, $\sigma=15$')
3232

33+
# Tweak spacing to prevent clipping of ylabel
34+
plt.subplots_adjust(left=0.15)
3335
plt.show()

examples/text_labels_and_annotations/text_demo_fontdict.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,6 @@
2020
plt.xlabel('time (s)', fontdict=font)
2121
plt.ylabel('voltage (mV)', fontdict=font)
2222

23+
# Tweak spacing to prevent clipping of ylabel
24+
plt.subplots_adjust(left=0.15)
2325
plt.show()

examples/ticks_and_spines/spines_demo.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
x = np.linspace(0, 2 * np.pi, 100)
1212
y = 2 * np.sin(x)
1313

14-
fig, (ax0, ax1) = plt.subplots(ncols=2)
14+
fig, (ax0, ax1) = plt.subplots(nrows=2)
1515

1616
ax0.plot(x, y)
1717
ax0.set_title('normal spines')
@@ -26,4 +26,6 @@
2626
ax1.yaxis.set_ticks_position('left')
2727
ax1.xaxis.set_ticks_position('bottom')
2828

29+
# Tweak spacing between subplots to prevent labels from overlapping
30+
plt.subplots_adjust(hspace=0.5)
2931
plt.show()

examples/ticks_and_spines/ticklabels_demo_rotation.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,6 @@
1313
plt.xticks(x, labels, rotation='vertical')
1414
# Pad margins so that markers don't get clipped by the axes
1515
plt.margins(0.2)
16+
# Tweak spacing to prevent clipping of tick-labels
17+
plt.subplots_adjust(bottom=0.15)
1618
plt.show()

0 commit comments

Comments
 (0)