热门标签 | 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箱线图



推荐阅读
  • [大整数乘法] java代码实现
    本文介绍了使用java代码实现大整数乘法的过程,同时也涉及到大整数加法和大整数减法的计算方法。通过分治算法来提高计算效率,并对算法的时间复杂度进行了研究。详细代码实现请参考文章链接。 ... [详细]
  • 本文介绍了九度OnlineJudge中的1002题目“Grading”的解决方法。该题目要求设计一个公平的评分过程,将每个考题分配给3个独立的专家,如果他们的评分不一致,则需要请一位裁判做出最终决定。文章详细描述了评分规则,并给出了解决该问题的程序。 ... [详细]
  • 本文主要解析了Open judge C16H问题中涉及到的Magical Balls的快速幂和逆元算法,并给出了问题的解析和解决方法。详细介绍了问题的背景和规则,并给出了相应的算法解析和实现步骤。通过本文的解析,读者可以更好地理解和解决Open judge C16H问题中的Magical Balls部分。 ... [详细]
  • 本文介绍了如何在给定的有序字符序列中插入新字符,并保持序列的有序性。通过示例代码演示了插入过程,以及插入后的字符序列。 ... [详细]
  • 展开全部下面的代码是创建一个立方体Thisexamplescreatesanddisplaysasimplebox.#Thefirstlineloadstheinit_disp ... [详细]
  • 不同优化算法的比较分析及实验验证
    本文介绍了神经网络优化中常用的优化方法,包括学习率调整和梯度估计修正,并通过实验验证了不同优化算法的效果。实验结果表明,Adam算法在综合考虑学习率调整和梯度估计修正方面表现较好。该研究对于优化神经网络的训练过程具有指导意义。 ... [详细]
  • 本文介绍了机器学习手册中关于日期和时区操作的重要性以及其在实际应用中的作用。文章以一个故事为背景,描述了学童们面对老先生的教导时的反应,以及上官如在这个过程中的表现。同时,文章也提到了顾慎为对上官如的恨意以及他们之间的矛盾源于早年的结局。最后,文章强调了日期和时区操作在机器学习中的重要性,并指出了其在实际应用中的作用和意义。 ... [详细]
  • WhenIusepythontoapplythepymysqlmoduletoaddafieldtoatableinthemysqldatabase,itdo ... [详细]
  • Python爬虫中使用正则表达式的方法和注意事项
    本文介绍了在Python爬虫中使用正则表达式的方法和注意事项。首先解释了爬虫的四个主要步骤,并强调了正则表达式在数据处理中的重要性。然后详细介绍了正则表达式的概念和用法,包括检索、替换和过滤文本的功能。同时提到了re模块是Python内置的用于处理正则表达式的模块,并给出了使用正则表达式时需要注意的特殊字符转义和原始字符串的用法。通过本文的学习,读者可以掌握在Python爬虫中使用正则表达式的技巧和方法。 ... [详细]
  • 【shell】网络处理:判断IP是否在网段、两个ip是否同网段、IP地址范围、网段包含关系
    本文介绍了使用shell脚本判断IP是否在同一网段、判断IP地址是否在某个范围内、计算IP地址范围、判断网段之间的包含关系的方法和原理。通过对IP和掩码进行与计算,可以判断两个IP是否在同一网段。同时,还提供了一段用于验证IP地址的正则表达式和判断特殊IP地址的方法。 ... [详细]
  • 这篇文章主要介绍了Python拼接字符串的七种方式,包括使用%、format()、join()、f-string等方法。每种方法都有其特点和限制,通过本文的介绍可以帮助读者更好地理解和运用字符串拼接的技巧。 ... [详细]
  • 学习Java异常处理之throws之抛出并捕获异常(9)
    任务描述本关任务:在main方法之外创建任意一个方法接收给定的两个字符串,把第二个字符串的长度减1生成一个整数值,输出第一个字符串长度是 ... [详细]
  • IOS开发之短信发送与拨打电话的方法详解
    本文详细介绍了在IOS开发中实现短信发送和拨打电话的两种方式,一种是使用系统底层发送,虽然无法自定义短信内容和返回原应用,但是简单方便;另一种是使用第三方框架发送,需要导入MessageUI头文件,并遵守MFMessageComposeViewControllerDelegate协议,可以实现自定义短信内容和返回原应用的功能。 ... [详细]
  • 本文介绍了在Python中使用FOR循环实现用户输入错误值3次后终止程序的方法。作者提到了自己对这个问题的困惑和尝试,并给出了解决方案。该方案要求代码必须包含FOR循环,但作者不确定是需要一个FOR循环还是3个FOR循环。最后,作者还给出了一些示例代码来说明如何将英里转换为公里和将英寸转换为厘米。 ... [详细]
  • 本文介绍了如何在wxpython中将matplotlib图表嵌入到自定义窗体中的方法。通过调用FigureCanvasWx类,可以实现在自定义窗体中显示matplotlib图表。同时,还介绍了与此相关的一些类和参数。 ... [详细]
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社区 版权所有