|
1 | 1 | from __future__ import print_function
|
2 |
| -from matplotlib.dates import bytespdate2num |
3 |
| -#from matplotlib.mlab import load |
4 | 2 | import numpy as np
|
5 |
| -from pylab import figure, show |
| 3 | +import matplotlib.pyplot as plt |
6 | 4 | import matplotlib.cbook as cbook
|
| 5 | +import matplotlib.dates as mdates |
| 6 | +from matplotlib.dates import bytespdate2num |
7 | 7 |
|
8 | 8 | datafile = cbook.get_sample_data('msft.csv', asfileobj=False)
|
9 | 9 | print('loading', datafile)
|
10 | 10 |
|
11 |
| -dates, closes = np.loadtxt( |
12 |
| - datafile, delimiter=',', |
13 |
| - converters={0: bytespdate2num('%d-%b-%y')}, |
14 |
| - skiprows=1, usecols=(0, 2), unpack=True) |
| 11 | +dates, closes = np.loadtxt(datafile, delimiter=',', |
| 12 | + converters={0: bytespdate2num('%d-%b-%y')}, |
| 13 | + skiprows=1, usecols=(0, 2), unpack=True) |
15 | 14 |
|
16 |
| -fig = figure() |
| 15 | +fig = plt.figure() |
17 | 16 | ax = fig.add_subplot(111)
|
18 | 17 | ax.plot_date(dates, closes, '-')
|
19 | 18 | fig.autofmt_xdate()
|
20 |
| -show() |
| 19 | +plt.show() |
0 commit comments