How to change the figure size of a seaborn axes or figure level plot
You can change the figure size of a Seaborn plot by using the set_size_inches()
method of the matplotlib.pyplot.figure
object and passing in the desired width and height. Here is an example:
import seaborn as sns
import matplotlib.pyplot as plt
# Generate a Seaborn plot
sns.lineplot(x=..., y=...)
# Get the current figure and set its size
fig = plt.gcf()
fig.set_size_inches(width, height)
# Show the plot
plt.show()
Watch a video course
Python - The Practical Guide
You can also use the figure
parameter of the seaborn plotting functions to set the size of the figure.
import seaborn as sns
# Generate a Seaborn plot
sns.lineplot(x=..., y=...,figure=plt.figure(figsize=(width, height)))
plt.show()
Note that the width and height values should be passed in as a tuple, and the units are inches.