在 python 代码中更改 "all" seaborn 图的大小

Change the size of "all" seaborn plots in the python code

我正在尝试确定 seaborn 在我的代码中生成的所有图形的大小(一个 kdeplot 和一个 jointplot)。

密码是:

plt.figure(figsize=(10,10))
sns.kdeplot(DF["x"], DF["y"], cmap="viridis")
plt.show()

plt.figure(figsize=(10,10))
sns.jointplot(DF["x"], DF["y"], color ="blue")
plt.show()

这段代码只改变了第一个数字(kde)的大小,第二个还是很小。 但是,如果第二个图也是kdeplot,那么大小就调整好了! 如果两者都是 jointplot,其中 none 个会改变大小! 解决办法是什么?为什么联合图的大小没有改变!?

您可以尝试分配联合图,然后设置图形大小:

import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns

x = np.arange(10)
y = x * 2

DF = pd.DataFrame({'x': x, 'y': y})

plt.figure(figsize=(10,10))
sns.kdeplot(DF["x"], DF["y"], cmap="viridis")

plt.figure(figsize=(10,10))
myplot = sns.jointplot(DF["x"], DF["y"], color ="blue")
myplot.fig.set_size_inches(10,10)