Python数据分析之可视化

Posted on 2016-06-22(星期三) 18:00 in Python数据分析


Python数据分析之可视化

matpalotlib库是Python最流行的可视化库 box

# Import the module for plotting
import matplotlib.pyplot as plt
plt.show(df.plot(kind = 'box'))

可以用pandas模块中集成R的ggplot主题来美化图表。要使用ggplot,只需要在上述代码中多加一行

import matplotlib.pyplot as plt
pd.options.display.mpl_style = 'default' # Sets the plotting display theme to ggplot2
df.plot(kind = 'box')

效果如下图表:

ggplot

seaborn模块,该模块也是一个统计数据可视化库:

seaborn

# Import the seaborn library
import seaborn as sns
# Do the boxplot
plt.show(sns.boxplot(df, widths = 0.5, color = "pastel"))

多性感的盒式图:

violinplot

plt.show(sns.violinplot(df, widths = 0.5, color = "pastel"))

distplot

plt.show(sns.distplot(df.ix[:,2], rug = True, bins = 15))

jointplot

with sns.axes_style("white"):
plt.show(sns.jointplot(df.ix[:,1], df.ix[:,2], kind = "kde"))

lmplot

plt.show(sns.lmplot("Benguet", "Ifugao", df))