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

Skip to content

Commit 54bdd3e

Browse files
committed
Merge pull request #4846 from ericmjl/mep12_plotfile_demo.py
mep12 on plotfile_demo.py
2 parents 6224f1e + a6111ca commit 54bdd3e

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed
Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,39 @@
1-
from pylab import plotfile, show, gca
1+
import matplotlib.pyplot as plt
2+
import numpy as np
3+
24
import matplotlib.cbook as cbook
35

46
fname = cbook.get_sample_data('msft.csv', asfileobj=False)
57
fname2 = cbook.get_sample_data('data_x_x2_x3.csv', asfileobj=False)
68

79
# test 1; use ints
8-
plotfile(fname, (0, 5, 6))
10+
plt.plotfile(fname, (0, 5, 6))
911

1012
# test 2; use names
11-
plotfile(fname, ('date', 'volume', 'adj_close'))
13+
plt.plotfile(fname, ('date', 'volume', 'adj_close'))
1214

1315
# test 3; use semilogy for volume
14-
plotfile(fname, ('date', 'volume', 'adj_close'), plotfuncs={'volume': 'semilogy'})
16+
plt.plotfile(fname, ('date', 'volume', 'adj_close'),
17+
plotfuncs={'volume': 'semilogy'})
1518

1619
# test 4; use semilogy for volume
17-
plotfile(fname, (0, 5, 6), plotfuncs={5: 'semilogy'})
20+
plt.plotfile(fname, (0, 5, 6), plotfuncs={5: 'semilogy'})
1821

1922
# test 5; single subplot
20-
plotfile(fname, ('date', 'open', 'high', 'low', 'close'), subplots=False)
23+
plt.plotfile(fname, ('date', 'open', 'high', 'low', 'close'), subplots=False)
2124

2225
# test 6; labeling, if no names in csv-file
23-
plotfile(fname2, cols=(0, 1, 2), delimiter=' ',
24-
names=['$x$', '$f(x)=x^2$', '$f(x)=x^3$'])
26+
plt.plotfile(fname2, cols=(0, 1, 2), delimiter=' ',
27+
names=['$x$', '$f(x)=x^2$', '$f(x)=x^3$'])
2528

2629
# test 7; more than one file per figure--illustrated here with a single file
27-
plotfile(fname2, cols=(0, 1), delimiter=' ')
28-
plotfile(fname2, cols=(0, 2), newfig=False, delimiter=' ') # use current figure
29-
gca().set_xlabel(r'$x$')
30-
gca().set_ylabel(r'$f(x) = x^2, x^3$')
30+
plt.plotfile(fname2, cols=(0, 1), delimiter=' ')
31+
plt.plotfile(fname2, cols=(0, 2), newfig=False,
32+
delimiter=' ') # use current figure
33+
plt.xlabel(r'$x$')
34+
plt.ylabel(r'$f(x) = x^2, x^3$')
3135

3236
# test 8; use bar for volume
33-
plotfile(fname, (0, 5, 6), plotfuncs={5: 'bar'})
37+
plt.plotfile(fname, (0, 5, 6), plotfuncs={5: 'bar'})
3438

35-
show()
39+
plt.show()

0 commit comments

Comments
 (0)