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

Skip to content

Commit 81928aa

Browse files
committed
mep12 on plotfile_demo.py
1 parent 263c06a commit 81928aa

File tree

1 file changed

+28
-14
lines changed

1 file changed

+28
-14
lines changed
Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,49 @@
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(
17+
fname,
18+
('date',
19+
'volume',
20+
'adj_close'),
21+
plotfuncs={
22+
'volume': 'semilogy'})
1523

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

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

2230
# 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$'])
31+
plt.plotfile(fname2, cols=(0, 1, 2), delimiter=' ',
32+
names=['$x$', '$f(x)=x^2$', '$f(x)=x^3$'])
2533

2634
# 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$')
35+
plt.plotfile(fname2, cols=(0, 1), delimiter=' ')
36+
plt.plotfile(
37+
fname2,
38+
cols=(
39+
0,
40+
2),
41+
newfig=False,
42+
delimiter=' ') # use current figure
43+
plt.xlabel(r'$x$')
44+
plt.ylabel(r'$f(x) = x^2, x^3$')
3145

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

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

0 commit comments

Comments
 (0)