diff --git a/examples/getting_started/plot_skore_product_tour.py b/examples/getting_started/plot_skore_product_tour.py index a90dfa4f9..8ec66bdcf 100644 --- a/examples/getting_started/plot_skore_product_tour.py +++ b/examples/getting_started/plot_skore_product_tour.py @@ -131,7 +131,7 @@ # %% import matplotlib.pyplot as plt -fig = plt.figure(layout="constrained", dpi=200) +fig = plt.figure(layout="constrained") plt.plot(df["param_alpha"], df["rmse"]) plt.xscale("log") plt.xlabel("Alpha hyperparameter") diff --git a/examples/getting_started/plot_working_with_projects.py b/examples/getting_started/plot_working_with_projects.py index 0b16b2074..ff8117ec5 100644 --- a/examples/getting_started/plot_working_with_projects.py +++ b/examples/getting_started/plot_working_with_projects.py @@ -231,7 +231,7 @@ def my_func(x): x = np.linspace(0, 2, 100) -fig, ax = plt.subplots(layout="constrained", dpi=200) +fig, ax = plt.subplots(layout="constrained") ax.plot(x, x, label="linear") ax.plot(x, x**2, label="quadratic") ax.plot(x, x**3, label="cubic") diff --git a/sphinx/conf.py b/sphinx/conf.py index c38c1695f..d1a3ec83e 100644 --- a/sphinx/conf.py +++ b/sphinx/conf.py @@ -64,6 +64,14 @@ "../examples/model_evaluation/plot_cross_validate", ] + +# https://sphinx-gallery.github.io/stable/advanced.html#resetting-before-each-example +def reset_mpl(gallery_conf, fname): + import matplotlib + + matplotlib.rcParams["figure.dpi"] = 200 + + # sphinx_gallery options sphinx_gallery_conf = { "examples_dirs": "../examples", # path to example scripts @@ -79,6 +87,7 @@ "backreferences_dir": "generated", "doc_module": "skore", "default_thumb_file": "./_static/images/Logo_Skore_Light@2x.svg", + "reset_modules": (reset_mpl, "seaborn"), } # intersphinx configuration