Is there any method to resize the entire plot as well as the font size and the line width in matplotlib or seaborn?

Viewed 267

There are many ways to change or set the figure size or the subplot size in matplotlib or seaborn, but as long as the size of a figure changes, say, becomes bigger, the font size, the line width, and the marker size will become relatively shorter visually. Therefore I wonder is there any method to resize the plot but keep all those things unchanged. It looks a bit like a scaling function in many pic-apps, but those scalings cannot enhance the pic quality while replotting the pic can.

1 Answers

You can use sns.set() property. Here is the sample code that may help you to understand.

This is with normal font.

import seaborn as sns
import matplotlib.pyplot as plt

penguins = sns.load_dataset("penguins")
sns.displot(data=penguins, x="flipper_length_mm", kde=True)

Normal Fonts

This is with Bigger font.

sns.set(font_scale=3)  # crazy big
g = sns.displot(data=penguins, x="flipper_length_mm", kde=True)
g.fig.set_figwidth(18.27)
g.fig.set_figheight(11.7)

Bigger Font

Related