I have this function and I want to change the size of the figure, however whatever values I put in the figsize, the figure size does not change. Can anybody suggest what's the problem? or if there is an alternative way for doing this?
def plot_comparison_barplots(df, bar_col, hue_col, scaled):
fig = plt.figure(figsize=(12,10))
fig.set_tight_layout(True)
plt.rcParams.update({'font.size': 9})
ax = sns.catplot(x=bar_col, y='count in %', data=df, hue=hue_col, kind='bar', order=scaled)
There is an easier way to implement this function, by using
subplots
instead offigure
, as when you use theset_tight_layout()
method, this automatically changes the location of the axes to make your graph look nicer, and make sure that none of the axis names are cut off. The quickest way of getting around this is to define your axes before theset_tight_layout()
method, so that thefigsize
parameter overrides it.Change:
fig = plt.figure(figsize=(12,10))
to
fig, ax = plt.subplots(figsize=(12,10))