python 情节熊猫
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 情节熊猫相关的知识,希望对你有一定的参考价值。
# Homepage: http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.plot.html
import pandas as pd
import matplotlib.pyplot as plt
# plot
DF.plot(x='year', y=['var1', 'var2'],kind="line",subplots=False,layout=(2,2))
# layout: distribution of multicharts.
# subplots: plot each line in different charts.
## customize datetime xticks
xticks = pd.date_range(start=df.index.tolist()[0], end=df.index.tolist()[-1])
df.plot(ax=ax,xticks=xticks.to_pydatetime())
ax.set_xticklabels([x.strftime('%Y %b %d,%a ') for x in xticks],rotation='vertical',fontsize='small')
# pandas plot linked to defined axes
fig, ax = plt.subplots()
DF.plot(ax=ax)
## scatter give custom points (size, color) -> 4D
df.plot(kind="scatter", x="var1", y="var2", alpha=0.4,
s=df["var3"]/100, label="var3",
c="var4", cmap=plt.get_cmap("jet"), colorbar=True,
)
plt.legend()
# SCATTER MATRIX
from pandas.tools.plotting import scatter_matrix
scatter_matrix(DF)
"""
kind : str
‘line’ : line plot (default)
‘bar’ : vertical bar plot
‘barh’ : horizontal bar plot
‘hist’ : histogram
‘box’ : boxplot
‘kde’ : Kernel Density Estimation plot
‘density’ : same as ‘kde’
‘area’ : area plot
‘pie’ : pie plot
‘scatter’ : scatter plot
‘hexbin’ : hexbin plot
"""
# display
plt.show()
以上是关于python 情节熊猫的主要内容,如果未能解决你的问题,请参考以下文章
熊猫情节栏:情节中出现其他列的图例
熊猫情节 axvspan
如何用熊猫把传说放在情节之外
如何用熊猫把传说放在情节之外
熊猫情节不显示
情节堆积条形图熊猫数据框