pythonmatplotlibplotseabornfigure

How to edit figure size in seaborn plot


I want to create 2 regplots from seaborn, both of which are subplots. I want to adjust the size of the figures but there is no attribute for figsize, height or aspect in sns.regplot. How do I alter the figsize?

CODE

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)

Solution

  • Use pyplot.subplots; change

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

    to something like

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

    adjusting the figsize as desired.