Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

Seaborn


使用 Seaborn 可视化分布

Seaborn 是一个库,它使用 Matplotlib 绘制图形。它将用于可视化随机分布。

安装 Seaborn。

如果您的系统上已经安装了PythonPIP,请使用以下命令安装它

C:\Users\您的用户名>pip install seaborn

如果您使用 Jupyter,请使用以下命令安装 Seaborn

C:\Users\您的用户名>!pip install seaborn

Distplots

Distplot 代表分布图,它以数组作为输入,并绘制与数组中点分布相对应的曲线。


导入 Matplotlib

使用以下语句在您的代码中导入 Matplotlib 模块的 pyplot 对象
import matplotlib.pyplot as plt

您可以在我们的Matplotlib 教程中了解有关 Matplotlib 模块的信息。


导入 Seaborn

使用以下语句在您的代码中导入 Seaborn 模块
import seaborn as sns

绘制 Distplot

示例

import matplotlib.pyplot as plt
import seaborn as sns

sns.distplot([0, 1, 2, 3, 4, 5])

plt.show()
自己试试 »

绘制不带直方图的 Distplot

示例

import matplotlib.pyplot as plt
import seaborn as sns

sns.distplot([0, 1, 2, 3, 4, 5], hist=False)

plt.show()
自己试试 »

注意:在本教程中,我们将使用:sns.distplot(arr, hist=False) 来可视化随机分布。


×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
[email protected]

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
[email protected]

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2024 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.