seaborn.displot将纵轴显示为概率
时间: 2023-06-05 12:08:34 浏览: 214
分布时应该怎么做?
为了将纵轴显示为概率分布,您可以将参数设置为norm_hist=True。这将替换计数标准化,以便纵轴表示概率密度函数。例如:seaborn.displot(data, x='variable', kde=True, rug=True, norm_hist=True)。希望对您有所帮助!
相关问题
seaborn.displot()
seaborn.displot() is a function in the seaborn library for Python, which allows you to create a histogram, a kernel density estimate (KDE) plot, and a rug plot all at once. It is a flexible and powerful tool for visualizing the distribution of a dataset.
The displot() function can handle both one-dimensional and two-dimensional data, and it can also be used to visualize relationships between variables. It allows you to customize the bins, the color of the plot, and the type of plot you want to create.
Some common parameters that can be passed to the displot() function include:
- data: The input data that you want to visualize.
- x, y: The variables to be plotted on the x and y axes.
- kind: The type of plot to be created, such as "hist", "kde", or "rug".
- bins: The number of bins to use for the histogram.
- color: The color of the plot.
- hue: The variable to use for grouping the data and creating multiple plots.
- multiple: Whether to create separate plots for each value of the hue variable.
Overall, seaborn.displot() is a useful function for quickly visualizing the distribution of a dataset, and it can be customized to create a wide range of different plots.
x = np.random.randn(100) ax = sns.displot(x) x = np.random.randn(100) ax = sns.displot(x) x = np.random.randn(100) ax = sns.displot(x) x = np.random.randn(100) ax = sns.displot(x) x = np.random.randn(100)ax = sns.displot(x) 写到pycharm里,pycharm为什么不出现图
在PyCharm中,你需要使用`plt.show()`来显示图形。添加这一行代码后,你的图形应该能够在PyCharm中正确显示。请尝试将以下代码添加到你的脚本中:
```python
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
sns.set_theme()
np.random.seed(0)
x = np.random.randn(100)
ax = sns.displot(x)
plt.show()
x = np.random.randn(100)
ax = sns.displot(x)
plt.show()
x = np.random.randn(100)
ax = sns.displot(x)
plt.show()
x = np.random.randn(100)
ax = sns.displot(x)
plt.show()
x = np.random.randn(100)
ax = sns.displot(x)
plt.show()
```
这样你就可以在PyCharm中看到生成的图形了。如果还有其他问题,请随时提问!
阅读全文