seaborn

Hey, folks! In our Seaborn tutorial, we will be focusing on Seaborn Kdeplot.

嘿伙计! 在我们的Seaborn教程中,我们将专注于Seaborn Kdeplot



什么是Kdeplot? (What is Kdeplot?)

Kdeplot is a Kernel Distribution Estimation Plot which depicts the probability density function of the continuous or non-parametric data variables i.e. we can plot for the univariate or multiple variables altogether. Using the Python Seaborn module, we can build the Kdeplot with various functionality added to it.

Kdeplot是一个内核分布估计图,它描述了连续或非参数数据变量的概率密度函数,即,我们可以为单变量或多个变量一起绘制图。 使用Python Seaborn模块 ,我们可以构建带有各种功能的Kdeplot。

In order to use the Seaborn module, we need to install and import the module using the below command:

为了使用Seaborn模块,我们需要使用以下命令安装和导入该模块:


pip install seabornimport seaborn


创建单变量Seaborn Kdeplot (Creating a Univariate Seaborn Kdeplot)

The seaborn.kdeplot() function is used to plot the data against a single/univariate variable. It represents the probability distribution of the data values as the area under the plotted curve.

seaborn.kdeplot()函数用于根据单个/单变量变量绘制数据。 它将数据值的概率分布表示为绘制曲线下的面积。

Syntax:

句法:


seaborn.kdeplot(data)

Example 1:

范例1:


import seaborn as sn
import matplotlib.pyplot as plt
import numpy as np
data = np.random.randn(200)
res = sn.kdeplot(data)
plt.show()

In the above example, we have generated some random data values using the numpy.random.randn() function.

在上面的示例中,我们使用numpy.random.randn()函数生成了一些随机数据值。

Output:

输出:

Univariate Seaborn Kdeplot单变量Seaborn Kdeplot

Example 2:

范例2:


import seaborn as sn
import matplotlib.pyplot as plt
import numpy as np
data = np.random.randn(200)
res = sn.kdeplot(data,color='green',shade=True)
plt.show()

In the above example, we have highlighted the plot using the parameter – ‘shade‘ to highlight the area under the curve. Further, we can set different colors to the plot using the parameter – ‘color‘.

在上面的示例中,我们使用参数-“ shade ”突出显示了曲线,以突出显示曲线下的区域 。 此外,我们可以使用参数“ color ”为绘图设置不同的颜色。

Output:

输出:

Univariate Seaborn Kdeplot With Shade And Color Parameter具有阴影和颜色参数的单变量Seaborn Kdeplot


创建双变量Seaborn Kdeplot (Creating a Bivariate Seaborn Kdeplot)

Seaborn Kdeplots can even be used to plot the data against multiple data variables or bivariate(2) variables to depict the probability distribution of one with respect to the other values.

Seaborn Kdeplots甚至可以用于针对多个数据变量或bivariate(2)变量绘制数据,以描绘一个变量相对于其他值的概率分布。

Syntax:

句法:


seaborn.kdeplot(x,y)

Thus, the distribution is represented as a contour plot depicting the relationship of the distribution between the two data variables.

因此,该分布表示为等高线图,描绘了两个数据变量之间的分布关系。

Example:

例:


import seaborn as sn
import matplotlib.pyplot as plt
import numpy as np
import pandas
data = pandas.read_csv("C:/mtcars.csv")
res = sn.kdeplot(data['mpg'],data['qsec'],color='blue',shade=True)
plt.show()

Output:

输出:

Bivariate Seaborn Kdeplot双变量Seaborn Kdeplot


沿垂直轴绘制Seaborn Kdeplot (Plotting Seaborn Kdeplot along the Vertical axis)

We can plot the Kdeplots along the y-axis using the below syntax:

我们可以使用以下语法沿y轴绘制Kdeplots:

Syntax:

句法:


seaborn.kdeplot(data,vertical=True)

Thus, by setting the ‘vertical‘ parameter to True, we can plot the distribution against the y-axis.

因此,通过将“ vertical ”参数设置为True ,我们可以针对y轴绘制分布。

Example:

例:


import seaborn as sn
import matplotlib.pyplot as plt
import numpy as np
import pandas
data = pandas.read_csv("C:/mtcars.csv")
res = sn.kdeplot(data['mpg'],vertical=True,color='blue',shade=True)
plt.show()

Output:

输出:

Univariate Seaborn Kdeplot Along Vertical Axis沿垂直轴的单变量Seaborn Kdeplot


在Seaborn Kdeplot中使用调色板 (Using color palettes within a Seaborn Kdeplot)

Different color palettes can be used along with the Seaborn plots to visualize the data in a better manner using the ‘cmap‘ parameter.

可以将不同的调色板与Seaborn图一起使用,以使用' cmap '参数以更好的方式可视化数据。

Different types of color palettes are available at Matplotlib Colormap.

Matplotlib Colormap提供了不同类型的调色板。

Syntax:

句法:


seaborn.kdeplot(data,cmap)

Example:

例:


import seaborn as sn
import matplotlib.pyplot as plt
import numpy as np
import pandas
data = pandas.read_csv("C:/mtcars.csv")
res = sn.kdeplot(data['mpg'],data['qsec'],shade=True,cmap="Purples_d")
plt.show()

Output:

输出:

Bivariate Seaborn Kdeplot With Color Palette带有调色板的双变量Seaborn Kdeplot


绘制两个阴影的双变量Kdeplots (Plotting two shaded Bivariate Kdeplots)

The two shaded Bivariate Kdeplots help in understanding the variation of the data in terms of the probability distribution of the bivariate group of data variables.

两个阴影阴影的双变量Kdeplots有助于根据数据变量的双变量组的概率分布来理解数据的变化。

Example:

例:


import seaborn as sn
import matplotlib.pyplot as plt
import numpy as np
import pandas
data = pandas.read_csv("C:/mtcars.csv")
sn.set(style='dark',)
res = sn.kdeplot(data['hp'],data['cyl'],shade=True,cmap="Purples_d")
res = sn.kdeplot(data['hp'],data['cyl'],shade=True,cmap="Blues")
plt.show()

Output:

输出:

Shaded Bivariate Seaborn Kdeplots阴影二元Seaborn Kdeplots


在Seaborn Kdeplot上添加了Colorbar (Addition of a Colorbar to a Seaborn Kdeplot)

A colorbar maps the pictorial representation of values against the original data values and helps visualize the data in a better manner.

colorbar将值的图形表示形式映射到原始数据值,并以更好的方式帮助可视化数据。

Syntax:

句法:


seaborn.kdeplot(data,cbar=True)

Example:

例:


import seaborn as sn
import matplotlib.pyplot as plt
import numpy as np
import pandas
data = pandas.read_csv("C:/mtcars.csv")
sn.set(style='dark',)
res=sn.kdeplot(data['hp'],data['cyl'],shade=True,cmap="Purples_d",cbar=True)
plt.show()

Output:

输出

Bivariate Seaborn Kdeplot With Cbar带Cbar的双变量Seaborn Kdeplot


结论 (Conclusion)

Seaborn module is purely built upon the Matplotlib module and the combination is extensively used to visualize the data in different forms.

Seaborn模块纯粹基于Matplotlib模块构建,并且该组合被广泛用于以不同形式可视化数据。

I would strongly recommend the readers to go through Python Matplotlib Tutorial for a better understanding about the basics of data visualization.

我强烈建议读者阅读Python Matplotlib教程 ,以更好地了解数据可视化的基础。



参考资料 (References)

  • Seaborn Kdeplot — DocumentationSeaborn Kdeplot —文档

翻译自: https://www.journaldev.com/40204/seaborn-kdeplot

seaborn

seaborn_Seaborn Kdeplot –综合指南相关推荐

  1. EOS账户和钱包综合指南

    EOS账户和钱包综合指南 注意:本教程适用于私有单节点测试网络,但只需稍作修改即可在公用测试网上使用. 介绍 教程受众 本教程适用于想了解钱包和账户管理,如何使用cleos来管理钱包和账户,以及钱包和 ...

  2. Kubernetes教程 - Kubernetes综合指南(Use Guide)

    英文原作者:Sahiti Kappagantula  翻译&转载:https://www.edureka.co/blog/kubernetes-tutorial/ Kubernetes教程 - ...

  3. 编写区块链_编写由区块链驱动的在线社区的综合指南

    编写区块链 by Sandeep Panda 通过Sandeep Panda 编写由区块链驱动的在线社区的综合指南 (A comprehensive guide to coding a blockch ...

  4. 【翻译】2020年云安全综合指南(风险,最佳实践,认证)

    翻译自:https://kinsta.com/blog/cloud-security/#what-is-kaspersky-security-cloud 云安全性包含技术,控件,流程和策略,这些技术, ...

  5. 「Adobe国际认证」平面设计师的,终极排版术语综合指南,都包含了哪些设计要点?

    要知道的排版术语 如果您是新媒体或者自媒体专员,没有理由不了解以下术语.如果您只是想了解更多有关平面设计的知识,也欢迎来到终极排版术语综合指南. 人物 它们只是符号.它可能有多少? 字体与字体 这两个 ...

  6. neo4j图形算法综合指南_网页设计中色彩使用的综合指南

    neo4j图形算法综合指南 There is a lot of material about color to be found online. But none of us has the time ...

  7. 21个热门的深度学习面试问答的综合指南

    本文列出了一系列热门的深度学习面试的问题,每一个问题都有相应的答案.认真阅读,或许你会对深度学习面试的知识有个全面的了解. 介绍 你打算参加深度学习面试吗?你是否已经迈出了第一步,申请了一个深度学习的 ...

  8. 宽高比和 16:9 宽高比:视频技术中宽高比的综合指南

    在视频世界中,"宽高比"在视觉内容的呈现和质量方面起着重要作用.宽高比是指图像或视频的宽度和高度之间的比例关系. 你的视频的宽高比会影响它在不同设备屏幕上的显示方式,从而影响观众体 ...

  9. 2022年,绩效管理周期的综合指南

    企业通常非常重视员工的绩效考核,但绩效管理所包含的内容远远超过单一的年度谈话.虽然绩效考核是员工在过去3个月.6个月甚至12个月的工作成果,但绩效管理周期远远超出了员工考核的范围. 事实上,绩效管理周 ...

最新文章

  1. vsco使用教程_VSCO如何使用 vsco新手教程
  2. Web UI 自动化测试环境搭建 (转载自51测试天地第三十九期上)
  3. C# 发送email邮件!
  4. 01c-1: 主流长远
  5. STM32F103 TIM4定时器
  6. java sqlite 多线程并发_Android中Sqlite数据库多线程并发问题
  7. 为什么字节跳动、腾讯、阿里都在用 Python??
  8. php导入csv 进度条,php 导入导出怎么做成有进度条??
  9. 来,教你写一手好SQL!
  10. leetCode 203. Remove Linked List Elements 链表
  11. 关于C#使用DataContractJsonSerializer来进行JSON解析
  12. Hermite多项式
  13. Microhard P900 900MHz跳频电台核心模块
  14. python 爬虫爬取bilibili
  15. my music / NightWish / Groove Coverage / DJ
  16. 比较好的网页视频播放器总结
  17. Domoticz 中接入斐讯 M1 空气质量检测仪
  18. 微信公众号开发(总结)
  19. 对讲机CE认证需做什么测试
  20. 模拟ARP欺骗攻击与防护

热门文章

  1. 有关二叉树方法java实现
  2. 利用WPF建立自适应窗口大小布局的WinForm窗口
  3. C语言的关键字 详解
  4. [转载] python中@property装饰器
  5. [转载] python(numpy) 实现神经网络训练 (卷积 全连接 池化)
  6. [转载] Pytorch入门实战-----逻辑回归识别手写数据集
  7. [转载] java clone方法_Java Calendar clone()方法与示例
  8. Broadwell I7-5775c/5675c BSOD 蓝屏问题
  9. H3C 单路径网络中环路产生过程(3)
  10. 《Java深入解析》阅读笔记二(运算符与表达式)