How do I change the figure size for a seaborn plot? How do I change the figure size for a seaborn plot? python python

How do I change the figure size for a seaborn plot?


You can also set figure size by passing dictionary to rc parameter with key 'figure.figsize' in seaborn set method:

import seaborn as snssns.set(rc={'figure.figsize':(11.7,8.27)})

Other alternative may be to use figure.figsize of rcParams to set figure size as below:

from matplotlib import rcParams# figure size in inchesrcParams['figure.figsize'] = 11.7,8.27

More details can be found in matplotlib documentation


You need to create the matplotlib Figure and Axes objects ahead of time, specifying how big the figure is:

from matplotlib import pyplotimport seabornimport myliba4_dims = (11.7, 8.27)df = mylib.load_data()fig, ax = pyplot.subplots(figsize=a4_dims)seaborn.violinplot(ax=ax, data=df, **violin_options)


Note that if you are trying to pass to a "figure level" method in seaborn (for example lmplot, catplot / factorplot, jointplot) you can and should specify this within the arguments using height and aspect.

sns.catplot(data=df, x='xvar', y='yvar',     hue='hue_bar', height=8.27, aspect=11.7/8.27)

See https://github.com/mwaskom/seaborn/issues/488 and Plotting with seaborn using the matplotlib object-oriented interface for more details on the fact that figure level methods do not obey axes specifications.


matomo