There are several plot types built-in to pandas, most of them statistical plots by nature:
- df.plot.area
- df.plot.barh
- df.plot.density
- df.plot.hist
- df.plot.line
- df.plot.scatter
- df.plot.bar
- df.plot.box
- df.plot.hexbin
- df.plot.kde
- df.plot.pie
You can also just call df.plot(kind='hist') or replace that kind argument with any of the key terms shown in the list above (e.g. 'box','barh', etc..)
Area Plot
df2.plot.area()
Bar Plot
df2.plot.bar()
Stacked Bar Plot
df2.plot.bar(stacked=True)
Histogram Plot
df1['A'].plot.hist()
Line Plot
df1.plot.line(x=df1.index,y='B',figsize=(12,3),lw=1)
Scatter Plot
df1.plot.scatter(x='A',y='B')
Scatter Plot with three variables
df1.plot.scatter(x='A',y='B',c='C')
Scatter Plot with third variable indicated by size
df1.plot.scatter(x='A',y='B',s=df1['C']*200)
Box Plot
df2.plot.box()
Hexagonal Bin Plot
df = pd.DataFrame(np.random.randn(1000, 2), columns=['a', 'b'])
df.plot.hexbin(x='a',y='b',gridsize=25)
Kernel Density Estimation (KDE) Plot
df2['a'].plot.kde()
Density Plot
df2.plot.density()
Comments
Post a Comment