I need some utility which can work with any platform, reason in my last blog we discuss on Matlab and Gnuplot, both are good tools but i need very light-weight tool which can work windows as well linux with same code.
================================================================
Visit my online store www.desikudi.in
================================================================
I have most of data reading utility in python, so i needed tool in python. i have chosen the matplotlib module for this task.
we need to import following python modules in our program.
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
from matplotlib.finance import plot_day_summary
import datetime
I have data in dictonary format, you can found my csv datareader code, so i had written following format of code. I like date in YYYYMMDD format because sorting of data based on date is easy.
def plotData(dictdata,numday):
qut=[]
if len(dictdata)>0:
i=0
for row in dictdata:
ts=row['timestamp']
op=row['open']
hp=row['high']
lp=row['low']
cp=row['close']
qut.append([datetime.datetime.strptime(ts,'%Y%m%d').date(),
float(op),float(cp),float(hp),float(lp)])
i=i+1
if i>numday:
break
plotquotes(qut)
def plotquotes(quotes):
ax = plt.axes()
ax.xaxis.set_major_formatter(mdates.DateFormatter('%Y%m%d'))
ax.xaxis.set_major_locator(mdates.WeekdayLocator(mdates.MONDAY))
ax.xaxis.set_minor_locator(mdates.DayLocator())
plot_day_summary(ax,quotes)
ax.xaxis_date()
ax.autoscale_view()
plt.setp( plt.gca().get_xticklabels(), rotation=45, horizontalalignment='right')
plt.show()
=============================================================
Visit my online store www.desikudi.in
================================================================
Visit my online store www.desikudi.in
================================================================
we need to import following python modules in our program.
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
from matplotlib.finance import plot_day_summary
import datetime
I have data in dictonary format, you can found my csv datareader code, so i had written following format of code. I like date in YYYYMMDD format because sorting of data based on date is easy.
def plotData(dictdata,numday):
qut=[]
if len(dictdata)>0:
i=0
for row in dictdata:
ts=row['timestamp']
op=row['open']
hp=row['high']
lp=row['low']
cp=row['close']
qut.append([datetime.datetime.strptime(ts,'%Y%m%d').date(),
float(op),float(cp),float(hp),float(lp)])
i=i+1
if i>numday:
break
plotquotes(qut)
def plotquotes(quotes):
ax = plt.axes()
ax.xaxis.set_major_formatter(mdates.DateFormatter('%Y%m%d'))
ax.xaxis.set_major_locator(mdates.WeekdayLocator(mdates.MONDAY))
ax.xaxis.set_minor_locator(mdates.DayLocator())
plot_day_summary(ax,quotes)
ax.xaxis_date()
ax.autoscale_view()
plt.setp( plt.gca().get_xticklabels(), rotation=45, horizontalalignment='right')
plt.show()
=============================================================
Visit my online store www.desikudi.in
No comments:
Post a Comment
would you like it. :)