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.

improvement: default stateless plotly plugin to zoom (#1921)

Akshay Agrawal53c7784f6e89
diff --git a/marimo/_output/formatters/plotly_formatters.py b/marimo/_output/formatters/plotly_formatters.py
index f7d3df79e2..7e97c4fc53 100644
--- a/marimo/_output/formatters/plotly_formatters.py
+++ b/marimo/_output/formatters/plotly_formatters.py
@@ -25,6 +25,10 @@ class PlotlyFormatter(FormatterFactory):
def _show_plotly_figure(
fig: plotly.graph_objects.Figure,
) -> tuple[KnownMimeType, str]:
+ dragmode = getattr(fig.layout, "dragmode", None)
+ if dragmode is None:
+ # Users are accustomed to default zoom.
+ fig.update_layout(dragmode="zoom")
json_str: str = pio.to_json(fig)
plugin = PlotlyFormatter.render_plotly_dict(json.loads(json_str))
return ("text/html", plugin.text)