Python3 入門:matplotlib でローソク足の表示 pandas numpy
海外のソースをみてほぼ写経
import pandas as pd import numpy from pylab import * import matplotlib.pyplot as plt from datetime import datetime import time from matplotlib.dates import DateFormatter, WeekdayLocator, HourLocator, \ DayLocator, MONDAY from matplotlib.finance import candlestick,\ plot_day_summary, candlestick2 %matplotlib inline mondays = WeekdayLocator(MONDAY) alldays = DayLocator() weekFormatter = DateFormatter('%b %d') dayFormatter = DateFormatter('%d') filename = "./4689.csv" df = pd.read_csv(filename, index_col=0) # データを読んで print(df) i=0 prices = [] for i in range(99): val = (date2num(datetime.strptime(df.ix[i].name.replace('-','/'), "%Y/%m/%d")) , df.ix[i].open , df.ix[i].close ,df.ix[i].high ,df.ix[i].low) prices.append(val) fig, ax = plt.subplots() fig.subplots_adjust(bottom=0.2) ax.xaxis.set_major_locator(mondays) ax.xaxis.set_minor_locator(alldays) ax.xaxis.set_major_formatter(weekFormatter) candlestick(ax, prices, width=0.6) ax.xaxis_date() ax.autoscale_view() plt.setp( plt.gca().get_xticklabels(), rotation=45, horizontalalignment='right') plt.show()
しかしこんな文字が!!
This function has been deprecated in 1.4 in favor of `candlestick_ochl`, which maintains the original argument order, or `candlestick_ohlc`, which uses the open-high-low-close order. This function will be removed in 1.5
mplDeprecation
どうやら1.5でなくなるらしい
せっかく覚えたのに。。。。orz