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.

smoke-tests: for theming different libraries (#2145)

Myles Scolnick8eee72352953
diff --git a/marimo/_smoke_tests/theming/altair_theme.py b/marimo/_smoke_tests/theming/altair_theme.py
new file mode 100644
index 0000000000..ccc73eed1a
--- /dev/null
+++ b/marimo/_smoke_tests/theming/altair_theme.py
@@ -0,0 +1,29 @@
+# /// script
+# requires-python = ">=3.11"
+# dependencies = [
+# "altair",
+# ]
+# ///
+
+import marimo
+
+__generated_with = "0.8.3"
+app = marimo.App(width="medium")
+
+
+def __():
+ import marimo as mo
+ import altair as alt
+
+ alt.themes
+ return alt, mo
+
+
+def __():
+ return
+
+
+if __name__ == "__main__":
+ app.run()
diff --git a/marimo/_smoke_tests/theming/bokeh_theme.py b/marimo/_smoke_tests/theming/bokeh_theme.py
index 1cfce1d4eb..aa2f7f6cf5 100644
--- a/marimo/_smoke_tests/theming/bokeh_theme.py
+++ b/marimo/_smoke_tests/theming/bokeh_theme.py
@@ -1,3 +1,9 @@
+# /// script
+# requires-python = ">=3.11"
+# dependencies = [
+# "bokeh",
+# ]
+# ///
import marimo
__generated_with = "0.8.3"
diff --git a/marimo/_smoke_tests/theming/matplotlib_theme.py b/marimo/_smoke_tests/theming/matplotlib_theme.py
new file mode 100644
index 0000000000..937b4824c6
--- /dev/null
+++ b/marimo/_smoke_tests/theming/matplotlib_theme.py
@@ -0,0 +1,78 @@
+# /// script
+# requires-python = ">=3.11"
+# dependencies = [
+# "matplotlib",
+# "numpy",
+# "marimo",
+# ]
+# ///
+
+import marimo
+
+__generated_with = "0.8.3"
+app = marimo.App(width="medium")
+
+
+def __():
+ import matplotlib.pyplot as plt
+ import numpy as np
+ import marimo as mo
+
+ return mo, np, plt
+
+
+def __(mo, plt):
+ mo.ui.table(plt.style.available, selection=None, page_size=2)
+ return
+
+
+def __(create_plot, plt):
+ plt.style.use('default')
+ create_plot().gca()
+ return
+
+
+def __(create_plot, plt):
+ plt.style.use('dark_background')
+ create_plot().gca()
+ return
+
+
+def __(np, plt):
+ def create_plot():
+ # Create sample data
+ x = np.linspace(0, 10, 100)
+ y1 = np.sin(x)
+ y2 = np.cos(x)
+ y3 = np.tan(x)
+ y4 = x**2
+
+ # Create the plot
+ fig, ax = plt.subplots(figsize=(10, 6))
+
+ # Plot multiple lines without specifying colors
+ ax.plot(x, y1, label='Sin')
+ ax.plot(x, y2, label='Cos')
+ ax.plot(x, y3, label='Tan')
+ ax.plot(x, y4, label='x^2')
+
+ # Customize the plot
+ ax.set_title('Dark Mode Plot with Auto Colors')
+ ax.set_xlabel('X-axis')
+ ax.set_ylabel('Y-axis')
+ ax.legend()
+
+ # Add a grid
+ ax.grid(True, linestyle='--', alpha=0.7)
+
+ return plt
+ return create_plot,
+
+
+if __name__ == "__main__":
+ app.run()
diff --git a/marimo/_smoke_tests/theming/plotly_theme.py b/marimo/_smoke_tests/theming/plotly_theme.py
new file mode 100644
index 0000000000..3b616bb643
--- /dev/null
+++ b/marimo/_smoke_tests/theming/plotly_theme.py
@@ -0,0 +1,56 @@
+# /// script
+# requires-python = ">=3.11"
+# dependencies = [
+# "marimo",
+# "plotly",
+# ]
+# ///
+
+import marimo
+
+__generated_with = "0.8.3"
+app = marimo.App(width="medium")
+
+
+def __():
+ import marimo as mo
+ import plotly.io as pio
+ import plotly.graph_objects as go
+
+ print("default theme:", pio.templates.default)
+ return go, mo, pio
+
+
+def __(go, pio):
+ pio.templates.default = "plotly_white"
+
+ go.Figure(
+ data=[go.Bar(y=[2, 1, 3])],
+ )
+ return
+
+
+def __(go, pio):
+ pio.templates.default = "plotly"
+
+ go.Figure(
+ data=[go.Bar(y=[2, 1, 3])],
+ )
+ return
+
+
+def __(go, pio):
+ pio.templates.default = "plotly_dark"
+
+ go.Figure(
+ data=[go.Bar(y=[2, 1, 3])],
+ )
+ return
+
+
+if __name__ == "__main__":
+ app.run()