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: holoviews composed views (#825)

Myles Scolnickffe0524587d6
diff --git a/marimo/_output/formatters/holoviews_formatters.py b/marimo/_output/formatters/holoviews_formatters.py
index a64f58fa58..ca9990a693 100644
--- a/marimo/_output/formatters/holoviews_formatters.py
+++ b/marimo/_output/formatters/holoviews_formatters.py
@@ -19,8 +19,9 @@ class HoloViewsFormatter(FormatterFactory):
from marimo._output import formatting
@formatting.formatter(hv.core.ViewableElement)
+ @formatting.formatter(hv.core.Layout)
def _show_chart(
- plot: hv.core.ViewableElement,
+ plot: hv.core.ViewableElement | hv.core.Layout,
) -> tuple[KnownMimeType, str]:
backend_output = hv.render(plot)
diff --git a/marimo/_smoke_tests/third_party/holoviews.py b/marimo/_smoke_tests/third_party/holoviews.py
index 56945be037..7d254f42fb 100644
--- a/marimo/_smoke_tests/third_party/holoviews.py
+++ b/marimo/_smoke_tests/third_party/holoviews.py
@@ -1,7 +1,8 @@
# Copyright 2024 Marimo. All rights reserved.
+
import marimo
-__generated_with = "0.2.2"
+__generated_with = "0.2.7"
app = marimo.App()
@@ -93,9 +94,37 @@ def __():
import hvplot.pandas
from bokeh.sampledata.penguins import data as df
- df.hvplot.scatter(x='bill_length_mm', y='bill_depth_mm', by='species')
+ df.hvplot.scatter(x="bill_length_mm", y="bill_depth_mm", by="species")
return df, hvplot
+def __(mo):
+ mo.md("# Composed Views")
+ return
+
+
+def __():
+ import polars as pl
+ from hvplot import polars
+
+ df3 = pl.DataFrame({"x": [1, 2, 3], "y": [1, 2, 3]})
+ df4 = pl.DataFrame({"x": [1, 2, 3], "y": [3, 2.5, 3]})
+ return df3, df4, pl, polars
+
+
+def __(df3, df4):
+ df3.hvplot.line("x", "y") * df4.hvplot.line("x", "y")
+ return
+
+
+def __(df3, df4):
+ df3.hvplot.line("x", "y") + df4.hvplot.line("x", "y")
+ return
+
+
if __name__ == "__main__":
app.run()