无法在ipython笔记本上显示图表 [英] Cannot show the graphs on ipython notebook

查看:230
本文介绍了无法在ipython笔记本上显示图表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在玩ipython笔记本并有一个问题。

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()

我成功地使用ipython控制台绘图。但是,我不能用ipython笔记本绘图。
看起来ipython笔记本什么也没做,python启动器永远弹出来。
有没有人有想法这里发生了什么?

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?

推荐答案

尝试在绘图代码前添加此行

try adding this line before your plotting code

%matplotlib inline

它告诉ipython笔记本显示inilne

It tells the ipython notebook to display plots inilne

这篇关于无法在ipython笔记本上显示图表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆