简体   繁体   English

在python代码中更改“所有” seaborn图的大小

[英]Change the size of “all” seaborn plots in the python code

I am trying to determine the size of ALL the figures produced by seaborn in my code (one kdeplot, and one jointplot). 我正在尝试确定代码中seaborn生成的所有图形的大小(一个kdeplot和一个jointplot)。

The code is: 代码是:

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()

With this code, only the size of the first figure (kde) is changed, and the second one is still small. 使用此代码,仅第一个图形的大小(kde)被更改,而第二个图形仍然很小。 However, if the second plot is a kdeplot as well, then the size is adjusted well! 但是,如果第二个图也是一个kdeplot ,那么大小调整得很好! If both are jointplot, none of them change the size! 如果两者都是关节图,则它们都不会改变尺寸! What is the solution? 解决办法是什么? Why size of the jointplot does not change!? 为什么关节图的大小不变!?

You could try asigning the jointplot and then set the figure size: 您可以尝试分配关节图,然后设置图形大小:

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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM