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.

Return html encoded matplotlib Figure from msgspec encoder hook (#9359)

Björn Schöllhorn-Friebel32ce9b5049ce
diff --git a/marimo/_messaging/msgspec_encoder.py b/marimo/_messaging/msgspec_encoder.py
index ae79f2f5c8..3eb2da5a01 100644
--- a/marimo/_messaging/msgspec_encoder.py
+++ b/marimo/_messaging/msgspec_encoder.py
@@ -170,6 +170,7 @@ def enc_hook(obj: Any) -> Any:
if isinstance(obj, matplotlib.figure.Figure):
html = as_html(vstack([str(obj), obj]))
mimetype, data = html._mime_()
+ return {"mimetype": mimetype, "data": data}
if isinstance(obj, Axes):
html = as_html(vstack([str(obj), obj]))