热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

seaborn箱线图_Seaborn线图的数据可视化

seaborn箱线图Hello,folks!Inthisarticle,wewillbetakingtheSeaborntutorialaheadandunderstandingt

seaborn箱线图

Hello, folks! In this article, we will be taking the Seaborn tutorial ahead and understanding the Seaborn Line Plot. We recently covered Seaborn HeatMaps so feel free to have a look if you’re interested in learning more about heatmaps.

大家好! 在本文中,我们将继续进行Seaborn教程,并了解Seaborn Line Plot 。 我们最近介绍了Seaborn HeatMaps,因此如果您有兴趣了解有关热图的更多信息,请随时查看。



什么是线图? (What is a Line Plot?)

Seaborn as a library is used in Data visualizations from the models built over the dataset to predict the outcome and analyse the variations in the data.

Seaborn是一个库,可用于在数据集中建立的模型的数据可视化中 ,以预测结果并分析数据的变化。

Seaborn Line Plots depict the relationship between continuous as well as categorical values in a continuous data point format.

Seaborn线图以连续数据点格式描述连续值和分类值之间的关系。

Throughout this article, we will be making the use of the below dataset to manipulate the data and to form the Line Plot. Please go through the below snapshot of the dataset before moving ahead.

在整个本文中,我们将使用以下数据集来操纵数据并形成线图。 在继续操作之前,请仔细阅读下面的数据集快照。

In the below dataset, the data variables — ‘cyl‘, ‘vs‘, ‘am‘, ‘gear‘ and ‘carb‘ are categorical variables because all the data values fall under a certain category or range of values.

在下面的数据集中,数据变量“ cyl ”,“ vs ”,“ am ”,“ gear ”和“ carb ”是分类变量,因为所有数据值都属于某个类别或值范围。

While the remaining data column falls under the integer/continuous variables because they carry discrete integer values with them.

而剩余的数据列属于整数/ 连续变量,因为它们带有离散整数值。

Input Dataset:

输入数据集:

Line Plot With style Parameter
Line Plot With style Parameter带有样式参数的线图


3.使用size参数在Seaborn中绘制多个线图 (3. Using size parameter to plot multiple line plots in Seaborn)

We can even use the size parameter of seaborn.lineplot() function to represent the multi data variable relationships with a varying size of line to be plotted. So it acts as a grouping variable with different size/width according to the magnitude of the data.

我们甚至可以使用seaborn.lineplot() functionsize参数来表示具有可变大小的待绘制线的多数据变量关系。 因此,它根据数据的大小充当大小/宽度不同的分组变量。

Syntax:

句法:


seaborn.lineplot(x, y, data, size)

Example 3:

范例3:


import pandas as pd
import seaborn as sns
import matplotlib.pyplot as pltdata = pd.read_csv("C:/mtcars.csv")
info = data.iloc[1:20,]
sns.lineplot(x = "drat", y = "mpg", data=info, hue="gear",style="gear",size="gear")
plt.show()

Input Dataset:

输入数据集:

Dataset For Multiple Line Plot
Dataset For Multiple Line Plot多线图数据集

Output:

输出:

Line Plot With size Parameter
Line Plot With size Parameter带有大小参数的线图


与线图一起使用不同的调色板 (Using different color palette along with Line Plot)

Seaborn colormap and palette define the color range for the visualization models. The parameter palette along with hue can be used for determining the color encoding scheme in terms of the data variable.

Seaborn颜色图和调色板定义了可视化模型的颜色范围。 参数palettehue可用于根据数据变量确定颜色编码方案。

For more color palettes, you can reference the link here: Color Palette

有关更多调色板,您可以在此处引用链接: 调色板

Syntax:

句法:


seaborn.lineplot(x,y,data,hue,palette)

Example:

例:


import pandas as pd
import seaborn as sns
import matplotlib.pyplot as pltdata = pd.read_csv("C:/mtcars.csv")
info = data.iloc[1:20,]
sns.lineplot(x = "drat", y = "mpg", data=info, hue="gear", palette = "Set1")
plt.show()

Output:

输出:

Line Plot Palette
Line Plot Palette
线图调色板


误差线添加到线图 (Addition of Error Bars to Line Plot)

Line Plots can be used to define the confidence levels/intervals in the plots to depict the error rates through the use of err_style parameter.

线图可用于定义图中的置信度水平/区间,以通过使用err_style参数来描述错误率。

Syntax:

句法:


seaborn.lineplot(x,y,data,err_style="bars")

Example:

例:


import pandas as pd
import seaborn as sns
import matplotlib.pyplot as pltdata = pd.read_csv("C:/mtcars.csv")
info = data.iloc[1:20,]
sns.lineplot(x = "cyl", y = "mpg",data=info, err_style="bars")
plt.show()

Output:

输出:

Line Plot With err_style Parameter
Line Plot With err_style Parameter带有err_style参数的线图


使用seaborn.set()函数设置不同的样式 (Setting different style using seaborn.set() function)

Python seaborn.set() function can be used to display the plot in a different background style.

Python seaborn.set() function可用于以不同背景样式显示图。

Syntax:

句法:


seaborn.set(style)

Example:

例:


import pandas as pd
import seaborn as sns
import matplotlib.pyplot as pltdata = pd.read_csv("C:/mtcars.csv")
info = data.iloc[1:20,]
sns.lineplot(x = "cyl", y = "mpg",data=info,hue="gear")
sns.set(style='dark',)
plt.show()

Output:

输出:

Line Plot With set() function
Line Plot With set() function带有set()函数的线图


结论 (Conclusion)

Thus, in this article, we have understood the Line Plots and the variations associated with it.

因此,在本文中,我们已经了解了线图及其相关的变化。

I strongly recommend the readers to go through Python Matplotlib tutorial to understand the Line Plots in a better manner.

我强烈建议读者阅读Python Matplotlib教程 ,以更好的方式了解线图。



参考资料 (References)

  • Seaborn Line Plot — Official Documentation

    Seaborn线图—官方文档

翻译自: https://www.journaldev.com/39342/seaborn-line-plot

seaborn箱线图



推荐阅读
author-avatar
呐街角-伤_774
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有