File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change 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
+
7
+ # Note: matplotlib.dates doesn't have bytespdate2num.
8
+ # This function was copied off the internet.
9
+ # Source: http://pythonprogramming.net/colors-fills-matplotlib-tutorial/
10
+ def bytespdate2num (fmt , encoding = 'utf-8' ):
11
+ strconverter = mdates .strpdate2num (fmt )
12
+ def bytesconverter (b ):
13
+ s = b .decode (encoding )
14
+ return strconverter (s )
15
+ return bytesconverter
7
16
8
17
datafile = cbook .get_sample_data ('msft.csv' , asfileobj = False )
9
18
print ('loading' , datafile )
13
22
converters = {0 : bytespdate2num ('%d-%b-%y' )},
14
23
skiprows = 1 , usecols = (0 , 2 ), unpack = True )
15
24
16
- fig = figure ()
25
+ fig = plt . figure ()
17
26
ax = fig .add_subplot (111 )
18
27
ax .plot_date (dates , closes , '-' )
19
28
fig .autofmt_xdate ()
20
- show ()
29
+ plt . show ()
You can’t perform that action at this time.
0 commit comments