First, the name of several Matplotlib map
- Line chart: plot
- Column charts: bar
- Histogram: hist
- Boxplot: box
- Density map: kde
- Area Chart: area
- Scatter: scatter
- Scatterplot matrix: scatter_matrix
- Pie: pie
Second, the line chart: plot
Average need to sort after the showing in FIG.
df.avg.value_counts().sort_index().plot()
Third, the column chart: bar
You can do first pivot , and then generates a bar graph
df.pivot_table(index='city',columns='education',values='avg',aggfunc='count').plot.bar()
If this is done stacked column chart , you can set the bar () parameters
df.pivot_table(index='city',columns='education',values='avg',aggfunc='count').plot.bar(stacked=True)
If you want to make a bar graph, you can modify the bar () method bar ()
df.pivot_table(index='city',columns='education',values='avg',aggfunc='count').plot.barh()
Fourth, the histogram: hist
df.avg.plot.hist()
To "education" field multi-dimensional analysis, the average draw a histogram,
alpha: transparency pattern;
stacked: whether the stack;
bins: Density;
df.groupby('education').apply(lambda x:x.avg).unstack().T.plot.hist(alpha=0.5,stacked=True,bins=30)
V. boxplot: box
Use one: the "Histogram" similar
df.groupby('education').apply(lambda x:x.avg).unstack().T.plot.box()
Usage of Two:
df.boxplot(column='avg',by='education')
Sixth, the density map: kde
df.avg.plot. wherein ()
Seven area chart: area
Usually the data classification (pivot) ,
df.pivot_table(index='avg',columns='education',values='positonId',aggfunc='count').plot.area()
Eight, scatter plots: scatter
Classified by company, and the average x-axis, y-axis is the number of
df.groupby('companyId').aggregate(['mean','count']).avg.plot.scatter(x='mean',y='count')
Nine, scatter plot matrix: scatter_matrix (Pandas function)
It applies to two or more parameters, combined two by two
matrix=df.groupby('companyId').aggregate(['mean','count',max]).avg
pd.plotting.scatter_matrix(matrix.query('count<50'),diagonal='kde')
Query: count is less than 50
diagonal: FIG modified type of (kde: FIG density)
Ten, pie charts: pie
df.city.value_counts().plot.pie(figsize=(6,6))
Length and width of the FIG: figsize