Pandas 中的 plot 和 iplot 有什么区别? [英] What is difference between plot and iplot in Pandas?

查看:78
本文介绍了Pandas 中的 plot 和 iplot 有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

plot() 和 iplot() 在 Jupyter Notebook 中显示图形的区别是什么?

What is the difference between plot() and iplot() in displaying a figure in Jupyter Notebook?

推荐答案

我刚开始在 Python (3.6.6) 中使用 iplot().我认为它在后台运行Matplotlib的情况下使用了Cufflinks包装器.对我来说,用简单的一行代码获得交互式绘图似乎是最简单的方法.

I just started using iplot() in Python (3.6.6). I think it uses the Cufflinks wrapper over plotly that runs Matplotlib under the hood. It is seems to be the easiest way for me to get interactive plots with simple one line code.

虽然它需要一些库来设置.例如,以下代码可在macOS上的Jupyter Notebook(5.0.0)中工作.此处的图是PNG,因此不是交互式的.

Although it needs some libraries to setup. For example, the code below works in Jupyter Notebook (5.0.0) on macOS. The plots attached here are PNG and therefore not interactive.

示例:(1)线条图(2)条形图 {下面的代码}

Example: (1) Line plot (2) Bar plot {code below}

# Import libraries
import pandas as pd
import numpy as np
from plotly import __version__
%matplotlib inline
import cufflinks as cf
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
init_notebook_mode(connected=True)

init_notebook_mode(connected=True)
cf.go_offline()

# Create random data
df = pd.DataFrame(np.random.randn(100,4), columns='Col1 Col2 Col3 Col4'.split())
df.head(2)

# Plot lines
df.iplot()

# Plot bars
df.iplot(kind='bar')

这篇关于Pandas 中的 plot 和 iplot 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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