我需要在图中添加两个子图.一个子图需要大约是第二个(相同高度)的三倍.我使用GridSpec和colspan论证完成了这个,但我想这样做,figure所以我可以保存为PDF.我可以使用figsize构造函数中的参数调整第一个数字,但是如何更改第二个图的大小?
如何更改seaborn中我的lmplot的数字大小?
这是我目前的代码,但显然figsize不被接受.
sns.lmplot(x="x", y="y", hue="category", data=df,fit_reg=False,
markers=["o", "x"], palette="Set1",figsize=(7,7));
Run Code Online (Sandbox Code Playgroud)
谢谢
我想知道当图包含多个子图(在我的情况下为5×2)时如何设置子图的大小.无论我允许整个人物有多大,子图总是看起来很小.我希望能直接控制该图中子图的大小.代码的简化版本粘贴在下面.
import numpy as np
import matplotlib.pyplot as plt
x = np.random.randn(20)
y = np.random.randn(20)
fig = plt.figure(figsize=(20, 8))
for i in range(0,10):
ax = fig.add_subplot(5, 2, i+1)
plt.plot(x, y, 'o')
ax.xaxis.set_visible(False)
ax.yaxis.set_visible(False)
# x and y axis should be equal length
x0,x1 = ax.get_xlim()
y0,y1 = ax.get_ylim()
ax.set_aspect(abs(x1-x0)/abs(y1-y0))
plt.show()
fig.savefig('plot.pdf', bbox_inches='tight')
Run Code Online (Sandbox Code Playgroud)