'How to change the figure size of a displot

I am new to Seaborn, and I am having some trouble changing my figure size. I have looked at examples and adapted it to my code, but nothing seems to be happening.

When executing the code, my displot size does not change. Instead, a random plot just gets generated above my displot (which is really, really small).

I am really unsure on what I am doing wrong in terms of changing the size of my figures. Therefore, could someone kindly point me in the correct direction in order to achieve this?

Thanks!

Code:

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
import seaborn as sns
sns.set()
fig, ax = plt.subplots(figsize=(12,8))
sns.displot(data=df, x="column_name", kde=True)


Solution 1:[1]

seaborn.displot is a figure-level plot, which does not work with fig, ax = plt.subplots(figsize=(12,8), dpi=300)

p = sns.displot(
    data=None,
    *,
    x=None,
    y=None,
    hue=None,
    row=None,
    col=None,
    weights=None,
    kind='hist',
    rug=False,
    rug_kws=None,
    log_scale=None,
    legend=True,
    palette=None,
    hue_order=None,
    hue_norm=None,
    color=None,
    col_wrap=None,
    row_order=None,
    col_order=None,
    ***height=5,**
    **aspect=1,***
    facet_kws=None,
    **kwargs,
)

by using height and aspect you can manage the size of it.

dpi can be adjusted with p.fig.set_dpi(100)

Solution 2:[2]

I hope this link help : how to change figure size in seaborn

fig, ax = plt.subplots(figsize=(10,10))

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Trenton McKinney
Solution 2 Fateme Pasandide