1

I'm playing around ipython notebook and have a question.

I was trying to visualize the stock price and the trading volume in a graph. My code is:

import datetime
import pandas as pd
import pandas.io.data
from pandas import DataFrame    
import matplotlib.pyplot as plt
from matplotlib import style

# skipping some code to get stock prices

ax1= plt.subplot(2,1,1)
ax1.plot(df.Close,label="sp500")
ax1.plot(ma,label='50MA')
plt.legend()

ax2=plt.subplot(2,1,2, sharex = ax1)
ax2.plot(df['H-L'],label='H-L')
plt.show()

And I succeeded plotting with ipython console. However, I cannot plot with ipython notebook. It seems like ipython notebook does nothing and python launcher popping up forever. Do anyone have ideas what's going on here?

user3368526
  • 1,612
  • 7
  • 27
  • 43

1 Answers1

3

try adding this line before your plotting code

%matplotlib inline

It tells the ipython notebook to display plots inilne

Bob Haffner
  • 6,148
  • 1
  • 28
  • 32
  • It doesn't work for me ! if you could check the code I posted on http://stackoverflow.com/questions/32011581/cannot-display-inline-chart-in-ipython-notebook I'd highly appreciate. thanks ! – Pedro Braz Aug 14 '15 at 13:43