我有以下情节
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
import pandas as pd
# read some dataframe and
sns.histplot(data=df['error'],bins=20, binrange=(0,2),kde=True)
所以你可以看到我限制了直方图的范围,但没有限制曲线的范围。而且曲线看起来低得可疑(而且是错误的)
然后
sns.histplot(data=df['c0_right_error'],bins=40, binrange=(-2,2),kde=True)
给我
我还尝试了密度图(我不知道它是否正确)
sns.histplot(data=df['c0_right_error'],bins=40, binrange=(-2,2),kde=True, stat='density')
我如何限制这些图中的范围?
您需要使用
ax.set_xlim
matplotlib 库。使用虚拟数据集请参阅下面的代码: