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

Skip to content

Commit 92a23cc

Browse files
committed
DOC: fixing/cleanup of units scatter example
1 parent 97d6185 commit 92a23cc

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

examples/units/units_scatter.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,13 @@
1313
from matplotlib import pyplot
1414

1515
# create masked array
16+
data = (1, 2, 3, 4, 5, 6, 7, 8)
17+
mask = (1, 0, 1, 0, 0, 0, 1, 0)
18+
xsecs = secs * np.ma.MaskedArray(data, mask, float)
1619

17-
18-
xsecs = secs*np.ma.MaskedArray((1, 2, 3, 4, 5, 6, 7, 8), (1, 0, 1, 0, 0, 0, 1, 0), float)
19-
#xsecs = secs*np.arange(1,10.)
20-
21-
fig, (ax1, ax2, ax3) = pyplot.figure(nrows=3, sharex=True)
22-
ax1 = fig.add_subplot(3, 1, 1)
20+
fig, (ax1, ax2, ax3) = pyplot.subplots(nrows=3, sharex=True)
2321
ax1.scatter(xsecs, xsecs)
22+
ax1.yaxis.set_units(secs)
2423
ax1.axis([0, 10, 0, 10])
2524

2625
ax2.scatter(xsecs, xsecs, yunits=hertz)
@@ -30,4 +29,5 @@
3029
ax3.yaxis.set_units(minutes)
3130
ax3.axis([0, 10, 0, 1])
3231

33-
fig.show()
32+
fig.tight_layout()
33+
pyplot.show()

0 commit comments

Comments
 (0)