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

pandas10minnutes_中英对照04
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')

pandas10minnutes_中英对照04

Original: https://blog.csdn.net/u012338969/article/details/124637662
Author: 雪龙无敌
Title: pandas10minnutes_中英对照04

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/756352/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球