Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

fix: import matplotlib.style explicitly (#2166)

Akshay Agrawal93ba0d98f784
diff --git a/marimo/_output/formatters/matplotlib_formatters.py b/marimo/_output/formatters/matplotlib_formatters.py
index e1ff62fae8..dfb2e35d67 100644
--- a/marimo/_output/formatters/matplotlib_formatters.py
+++ b/marimo/_output/formatters/matplotlib_formatters.py
@@ -58,7 +58,7 @@ class MatplotlibFormatter(FormatterFactory):
return ("text/plain", str(bc))
def apply_theme(self, theme: Theme) -> None:
- import matplotlib # type: ignore
+ import matplotlib.style # type: ignore
matplotlib.style.use(
"dark_background" if theme == "dark" else "default"
diff --git a/pyproject.toml b/pyproject.toml
index 685dd0dd2d..d40815fbc7 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -134,6 +134,7 @@ testoptional = [
"pandas>=1.5.3",
"pandas-stubs>=1.5.3.230321",
"geopandas~=0.13.0",
+ "matplotlib~=3.9.2; python_version > \"3.8\"",
"pyarrow>=15.0.2,<16",
"pyarrow-stubs>=10.0.1.9",
"pillow~=10.4.0",