import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
np.random.seed(0)
n, p = 40, 8
d = np.random.normal(0, 2, (n, p))
d += np.log(np.arange(1, p + 1)) * -5 + 10
# plot
sns.set_style('ticks')
fig, ax = plt.subplots()
# the size of A4 paper
fig.set_size_inches(11.7, 8.27)
sns.violinplot(data=d, inner="points", ax=ax)
sns.despine()
fig.savefig('example.png')
您需要提前创建matplotlib图形和轴对象,指定图形的大小:
您还可以通过在seaborn
set
方法中将dictionary传递给具有键'figure.figsize'
的rc
参数来设置图形大小:另一种选择是使用
figure.figsize
的rcParams
设置图形大小,如下所示:有关详细信息,请参见matplotlib documentation
您可以将上下文设置为
poster
或手动设置fig_size
。相关问题 更多 >
编程相关推荐