Pandas 中的 plot 和 iplot 有什么区别?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/49880314/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is difference between plot and iplot in Pandas?
提问by Nons
What is the difference between plot() and iplot() in displaying a figure in Jupyter Notebook?
在 Jupyter Notebook 中显示图形时 plot() 和 iplot() 有什么区别?
采纳答案by Nilesh Ingle
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.
我刚开始在 Python (3.6.6) 中使用 iplot()。我认为它使用 Cufflinks 包装器而不是在后台运行 Matplotlib 的 plotly。对我来说,用简单的一行代码获得交互式绘图似乎是最简单的方法。
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.
虽然它需要一些库来设置。例如,以下代码适用于 macOS 上的 Jupyter Notebook (5.0.0)。此处附上的图是 PNG 格式,因此不具有交互性。
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')
回答by lwileczek
iplot
is interactive plot. Plotlytakes Python code and makes beautiful looking JavaScript plots. They let you have a lot of control over how these plots look and they let you zoom, show information on hover and toggle data to be viewed on the chart. Tutorial.plot
command = Matplotlib which is more old-school. It creates static charts.So there is not much hover information really, and you have to rerun the code to change anything. It was made after MATLABwhich is an older program, so some people say it looks worse. It has a lot of options though and gives you a good amount of control over plots. It'll probably be created faster than a Plotly chart will be if you have a huge data set, but I wouldn't suspect much. Tutorial.Matplotlib is standard and has been around longer, so there is a lot of information on it. Hereis a blog post talking about different plotting packages in Python.
iplot
是互动情节。Plotly 使用Python 代码制作漂亮的 JavaScript 绘图。它们让您可以对这些图的外观进行大量控制,并且可以让您缩放、显示悬停信息并切换要在图表上查看的数据。教程。plot
command = Matplotlib 更老派。它创建静态图表。所以实际上没有多少悬停信息,您必须重新运行代码才能更改任何内容。它是在旧程序MATLAB之后制作的,所以有人说它看起来更糟。不过,它有很多选择,让您可以很好地控制情节。如果您拥有庞大的数据集,它的创建速度可能会比 Plotly 图表更快,但我不会怀疑太多。教程。Matplotlib 是标准的并且存在的时间更长,所以有很多关于它的信息。这是一篇讨论 Python 中不同绘图包的博客文章。