10 minutes to pandas英文网址
pandas10minnutes_中英对照01
pandas10minnutes_中英对照02
pandas10minnutes_中英对照03
pandas10minnutes_中英对照04
本次主要讲以下部分:
11.Plotting 绘图
11.Plotting 绘图
See the Plotting docs.
We use the standard convention for referencing the matplotlib API:
参见绘图文档。
我们使用标准约定来引用matplotlib API:
import matplotlib.pyplot as plt
plt.close("all")
The close() method is used to close a figure window:
close()方法用于关闭图形窗口:
import pandas as pd
ts = pd.Series(np.random.randn(1000), index=pd.date_range("1/1/2000", periods=1000))
ts = ts.cumsum()
ts.plot();
If running under Jupyter Notebook, the plot will appear on plot(). Otherwise use matplotlib.pyplot.show to show it or matplotlib.pyplot.savefig to write it to a file.
如果在Jupyter Notebook下运行,绘图通过plot()显示。否则使用matplotlib.pyplot.show 来显示它或matplotlib.pyplot.savefig将其写入文件中。
plt.show()
On a DataFrame, the plot() method is a convenience to plot all of the columns with labels:
在DataFrame上,plot()方法可以方便地对含有标签的所有列进行绘图:
df = pd.DataFrame(
np.random.randn(1000, 4), index=ts.index, columns=["A", "B", "C", "D"]
)
df = df.cumsum()
plt.figure()
df.plot()
plt.legend(loc='best')