-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathgraph.py
More file actions
executable file
·39 lines (31 loc) · 887 Bytes
/
graph.py
File metadata and controls
executable file
·39 lines (31 loc) · 887 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/python
# basicgraphy.py
# William C. Gunnells
#
# Script to graph stocks
# intra day data
import time
import datetime
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.ticker as mticker
import matplotlib.dates as mdates
mystock="AAPL"
def graphData(stock):
stockFile=stock+".txt"
date,closep,highp,lowp,openp,volume= np.loadtxt(stockFile,delimiter=',',unpack=True,
converters={0: mdates.strpdate2num('%Y%m%d')})
fig=plt.figure()
ax1=plt.subplot(1,1,1) # how much by how much by
ax1.plot(date,openp)
ax1.plot(date,highp)
ax1.plot(date,lowp)
ax1.plot(date,closep)
#pretty it up
ax1.xaxis.set_major_locator(mticker.MaxNLocator(10)) #max10days
ax1.xaxis.set_major_formatter(mdates.DateFormatter('%Y-%m-%d'))
# rotate
for label in ax1.xaxis.get_ticklabels():
label.set_rotation(45)
plt.show()
graphData(mystock)