更改 seaborn kdeplot 的图像限制 [英] Change image limits of seaborn kdeplot
本文介绍了更改 seaborn kdeplot 的图像限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我使用 shade 参数设置为 True 制作 seaborn.kdeplot 时,背景为白色.如果在更宽的范围(此处为蓝线)上绘制了其他内容,则此背景不会扩展到整个图.如何让 kdeplot扩展"到整个情节?
When I make a seaborn.kdeplot with the shade parameter set as True, the background is white. This background does not extend to the whole plot if there is something else that is plotted on a wider range (here, the blue line). How can I get kdeplot to "extend" to the whole plot?
(最终,让 kdeplot 的第一个阴影是透明的也会成功)
(Eventually, having the first shade of kdeplot being transoarent would also make the trick)
例子:
import seaborn as sns
import numpy as np
import matplotlib.pyplot as plt
plt.plot([-3, 3],[0,60])
points = np.random.multivariate_normal([0, 0], [[1, 2], [2, 20]], size=1000)
sns.kdeplot(points, shade=True)
plt.show()
推荐答案
有效:
import seaborn as sns
import numpy as np
import matplotlib.pyplot as plt
points = np.random.multivariate_normal([0, 0], [[1, 2], [2, 20]], size=1000)
plt.plot([-3, 3],[0,60])
ax = sns.kdeplot(points, shade=True)
ax.collections[0].set_alpha(0)
plt.show()
这篇关于更改 seaborn kdeplot 的图像限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文