Plotting#

marimo supports all major plotting libraries, including matplotlib, seaborn, plotly, and altair. Just import your plotting library of choice and use it as you normally would.

Reactive plots coming soon!

We’re working on a way to let you select data in a plot with your mouse, and have your selection automatically passed to Python — stay tuned!

Tip: outputting matplotlib plots. To output a matplotlib plot in a cell’s output area, include its Axes or Figure object as the last expression in your notebook. For example:

plt.plot([1, 2])
# plt.gca() gets the current `Axes`
plt.gca()

or

fig, ax = plt.subplots()

ax.plot([1, 2])
ax

If you want to output the plot in the console area, use plt.show() or fig.show().

marimo.mpl.interactive(figure: Figure | Axes) Html#

Render a matplotlib figure using an interactive viewer.

The interactive viewer allows you to pan, zoom, and see plot coordinates on mouse hover.

Example:

plt.plot([1, 2])
# plt.gcf() gets the current figure
mo.mpl.interactive(plt.gcf())

Args:

  • figure: a matplotlib Figure or Axes object

Returns:

  • An interactive matplotlib figure as an Html object