[Python Tutorial] Drawing a Violin Plot

黄舟
Release: 2017-02-07 16:13:04
Original
7142 people have browsed it

小提琴图(Violinplot)可以理解为箱图(Boxplot)加上密度图(Kdensity),本文简单介绍在Python中如何绘制该图,使用数据为Stata软件系统自带auto数据(已导出为CSV格式)。

导入命令

1)设置工作环境
%cd "F:\\Dropbox\\python"2)导入程序包import pandas as pd
import seaborn as sns
3)读取数据tips=pd.read_csv("stata_auto.csv")
4)定义并绘制图像
sns.set(style="whitegrid",palette="pastel",color_codes=ture)
sns.violinplot(x="rep78", y="mpg", data=tips, split=True,inner="quart")
sns.despine(left=True)
Copy after login

输出图像如下

[Python Tutorial] Drawing a Violin Plot

以上就是【Python教程】绘制小提琴图的内容,更多相关内容请关注PHP中文网(m.sbmmt.com)!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!