8000 use tight_layout + typos/minor fixes · matplotlib/matplotlib@367647e · GitHub
[go: up one dir, main page]

Skip to content

Commit 367647e

Browse files
committed
use tight_layout + typos/minor fixes
1 parent f3760b2 commit 367647e

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

examples/api/two_scales.py

Lines changed: 6 additions & 5 deletions
< 4868 /tr>
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@
2020

2121
def two_scales(ax1, time, data1, data2, c1, c2):
2222
"""
23-
2423
Parameters
2524
----------
26-
ax : axis
25+
ax1 : axis
2726
Axis to put two scales on
2827
2928
time : array-like
@@ -43,10 +42,11 @@ def two_scales(ax1, time, data1, data2, c1, c2):
4342
4443
Returns
4544
-------
46-
ax : axis
45+
ax1 : axis
4746
Original axis
4847
ax2 : axis
4948
New twin axis
49+
5050
"""
5151
ax2 = ax1.twinx()
5252

@@ -56,8 +56,8 @@ def two_scales(ax1, time, data1, data2, c1, c2):
5656

5757
ax2.plot(time, data2, color=c2)
5858
ax2.set_ylabel('sin')
59-
return ax1, ax2
6059

60+
return ax1, ax2
6161

6262
# Create some mock data
6363
t = np.arange(0.01, 10.0, 0.01)
@@ -68,7 +68,6 @@ def two_scales(ax1, time, data1, data2, c1, c2):
6868
fig, ax = plt.subplots()
6969
ax1, ax2 = two_scales(ax, t, s1, s2, 'r', 'b')
7070

71-
7271
# Change color of each axis
7372
def color_y_axis(ax, color):
7473
"""Color your axes."""
@@ -77,4 +76,6 @@ def color_y_axis(ax, color):
7776
return None
7877
color_y_axis(ax1, 'r')
7978
color_y_axis(ax2, 'b')
79+
80+
fig.tight_layout() # otherwise y-labels are slightly clipped
8081
plt.show()

0 commit comments

Comments
 (0)
0