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.
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')