w*s 发帖数: 7227 | 1 Ok i found this code online, works fine except i want to see date in the
xlabel.
import numpy as np
import pandas
import matplotlib.pyplot as plt
from matplotlib.finance import candlestick, candlestick2
import matplotlib.dates as mdates
from pandas.io.data import DataReader
import datetime
# get daily stock price data from yahoo finance for S&P500
start = datetime.datetime(2015, 11, 1)
end = datetime.datetime(2016, 2, 11)
SP = DataReader("spy", "yahoo", start, end)
SP.reset_index(inplace=True)
print(SP.columns)
SP['Date2'] = SP['Date'].apply(lambda date: mdates.date2num(date.to_
pydatetime()))
fig, ax = plt.subplots()
csticks = candlestick(ax, SP[['Date2', 'Open', 'Close', 'High', 'Low']].
values)
plt.show()
Does this df.plot(kind='ohlc') exist for the latest version of Pandas now? |