I'm using seaborn version o.4 and matplotlib version 1.42
I have a chart displays both line and marker through simple plot command eg.
plt.plot([1,5,3,8,4],'-bo');
Due to a potential bug (https://github.com/mwaskom/seaborn/issues/344), after import seaborn, same code shows line only without marker.
import seaborn as sb
plt.plot([1,5,3,8,4],'-bo');
So my question is: after import seaborn, Is there a way to reset all the parameters back to original?
Yes, call seaborn.reset_orig
.
To refresh Matplotlib's configuration side effects often encountered with Seaborn:
import matplotlib as mpl
import matplotlib.pyplot as plt
import seaborn.apionly as sns
Run this:
import importlib
importlib.reload(mpl); importlib.reload(plt); importlib.reload(sns)
For old Python2 code:
import imp
imp.reload(mpl); imp.reload(plt); imp.reload(sns)
Note: None of the following correctly restores the state of matplotlib:
- sns.reset_orig()
- sns.reset_defaults()
- mpl.rcParams.update(mpl.rcParamsDefault)
You can save the rcParams
you want, before changing the style with seaborn (note that seaborn no longer changes the rcParams
upon import):
import matplotlib as mpl
my_params = mpl.rcParams
# apply some change to the rcparams here
mpl.rcParams.update(my_params)
Note that both these
mpl.rcParams.update(mpl.rcParamsOrig)
mpl.rcParams.update(mpl.rcParamsDefault)
restores almost all rcParams
to their default value. The few that will be different can easily be viewed by (I ran this in a Jupyter Notebook):
# Differences between current params and `Default`
for key in mpl.rcParamsDefault:
if not mpl.rcParamsDefault[key] == mpl.rcParams[key]:
print(key, mpl.rcParamsDefault[key], mpl.rcParams[key])
## backend agg module://ipykernel.pylab.backend_inline
## figure.dpi 100.0 72.0
## figure.edgecolor w (1, 1, 1, 0)
## figure.facecolor w (1, 1, 1, 0)
## figure.figsize [6.4, 4.8] [6.0, 4.0]
## figure.subplot.bottom 0.11 0.125
and
# Differences between `Default` and `Orig`
for key in mpl.rcParamsDefault:
if not mpl.rcParamsDefault[key] == mpl.rcParamsOrig[key]:
print(key, mpl.rcParamsDefault[key], mpl.rcParamsOrig[key])
## backend agg Qt5Agg
One can simply call the seaborn.set()
function, with no function parameters, see [seaborn tutorial][1]
.