-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdata-visualisation-part2.py
35 lines (31 loc) · 1.13 KB
/
data-visualisation-part2.py
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
#!/usr/bin/python
# -*- coding: utf-8 -*-
import matplotlib
import matplotlib.pyplot as plt
import matplotlib.ticker as mticker
import matplotlib.dates as mdates
from matplotlib.dates import bytespdate2num
import numpy as np
from matplotlib import style
style.use('ggplot')
def graphRawFX():
(date, bid, ask) = np.loadtxt('GBPUSD1d.txt', unpack=True,
delimiter=',',
converters={0: mdates.bytespdate2num('%Y%m%d%H%M%S'
)})
fig = plt.figure(figsize=(10, 7))
ax1 = plt.subplot2grid((40, 40), (0, 0), rowspan=40, colspan=40)
ax1.plot(date, bid)
ax1.plot(date, ask)
ax1.xaxis.set_major_formatter(mdates.DateFormatter('%Y-%m-%d %H:%M:%S'
))
plt.grid(True)
for label in ax1.xaxis.get_ticklabels():
label.set_rotation(45)
plt.subplots_adjust(bottom=.23)
plt.gca().get_yaxis().get_major_formatter().set_useOffset(False)
ax1_2 = ax1.twinx()
ax1_2.fill_between(date, 0, ask - bid, facecolor='g', alpha=.3)
plt.subplots_adjust(bottom=.23)
plt.show()
graphRawFX()