Using plt.ioff
disables interactive mode and storing figure in a variable won't display any output:
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
plt.ioff()
sns.set_theme(style="darkgrid")
# Load an example dataset with long-form data
fmri = sns.load_dataset("fmri")
# Plot the responses for different events and regions
fig = sns.lineplot(x="timepoint", y="signal",
hue="region", style="event",
data=fmri)
But using plt.show()
reverses the effect and show the output figure:
# Import modules here
plt.ioff()
# Set theme and load data here
fig = sns.lineplot(x="timepoint", y="signal",
hue="region", style="event",
data=fmri)
plt.show()
How the Jupyter Notebook output looks like when the above code is used:

The code for plotting the Timeseries plot comes from here.