【问题标题】:How to edit figure size in seaborn plot如何在 seaborn 图中编辑图形大小
【发布时间】:2020-07-01 13:34:43
【问题描述】:

我想从 seaborn 创建 2 个正则图,它们都是子图。我想调整图形的大小,但 sns.regplot 中没有 figsize、height 或 aspect 的属性。如何更改 figsize?

代码

fig = plt.figure()
ax0 = fig.add_subplot(121)
ax1 = fig.add_subplot(122)

sns.regplot(x='Reputation',y='Views',data=df_users,ax=ax0)
sns.regplot(x='Reputation',y='UpVotes',data=df_users,ax=ax1)

【问题讨论】:

  • fig, (ax0, ax1) = plt.subplots(ncols=2, figsize=(10, 10))?
  • 这行得通,我必须在编写此代码之前删除 ax0 和 ax1。

标签: python-3.x matplotlib plot seaborn figure


【解决方案1】:

使用pyplot.subplots;改变

fig = plt.figure()
ax0 = fig.add_subplot(121)
ax1 = fig.add_subplot(122)

类似

fig, (ax0, ax1) = plt.subplots(ncols=2, figsize=(10, 10))

根据需要调整figsize

【讨论】:

    猜你喜欢
    • 2020-05-24
    • 1970-01-01
    • 2021-10-02
    • 2014-11-27
    相关资源
    最近更新 更多