I executed the code below and no errors showed in the process, but plt.show() could not work and showed nothing in the end! I'm confused and want to know why......
from mpl_finance import candlestick_ohlc
import matplotlib.dates as mdates
import matplotlib.pyplot as plt
import quandl
df = quandl.get("EOD/AAPL", authtoken="fzTPb-TWywaPkbdAS1VF")
df['Date'] = df.index.map(mdates.date2num)
ohlc = df[['Date','Open','High','Low','Close']]
f1, ax = plt.subplots(figsize = (10,5))
candlestick_ohlc(ax, ohlc.values, width=.6, colorup='green', colordown='red')
ax.xaxis.set_major_formatter(mdates.DateFormatter('%Y-%m'))
plt.show()
In jupyter notebook it makes sense to define a backend, e.g. %matplotlib inline
or %matplotlib notebook
.
When then running your code in a singe cell it should show you the plot.
If you need to run it in seperate cells, plt.show()
will not know what to show from previous cells. So in that case, state the figure instead,
f1
to show the figure f1
.