将xlabel和ylabel统一到一个子图中,并将seaborn regplots作为子图

2024-05-14 19:47:15 发布

您现在位置:Python中文网/ 问答频道 /正文

我有下面的代码,绘制两个seaborn regplots相邻。我无法显示统一的xlabel和ylabel。它当前正在写入df的列名(对于xlabel,var1,对于ylabel是var2)。在

我想定制标签。我试了ax1.set_xlabel("New custom label")但没用。不知道还能做什么。在

f, (ax1, ax2) = plt.subplots(figsize=(20, 6), ncols=2, sharey=True)
f.suptitle("Unified Title of Graph")
plt.subplots_adjust(top=0.85)

x_jit = 0.075
y_jit = 0.05

ax1.set_title("Mini Title 1")
ax1.set_xlim([0,1])
ax1.set_ylim([0,100])
sns.regplot(df1['var1'], df1['var2'],ax=ax1, marker='o', color='#39ad48', label="label1", scatter=True, x_jitter=x_jit, y_jitter=y_jit, x_ci=95)


ax2.set_title('Mini Title 2')
ax2.set_xlim([0,1.01])
sns.regplot(df2['var1'], df2['var2'],ax=ax2, marker='o', color='#d9544d', label="label2", scatter=True, x_jitter=x_jit, y_jitter=y_jit,x_ci=95) 

plt.show()

Tags: truetitlepltlabeljitsetvar1var2

热门问题