Skip to content

matplotlib plots missing when in stacks or embeds #7677

@yairchu

Description

@yairchu

Describe the bug

Since 0892064, non-interactive matplotlib plots no longer show up when they are contained in UIs via combinators like hstack, accordion, as well as marimo app embed()s

Very simple example:

_fig = plt.figure()
plt.plot([1, 2], [3, 2])
mo.hstack([mo.md("A figure:"), _fig], justify="start")

Will you submit a PR?

  • Yes

Environment

Details
{
  "marimo": "0.17.7",
  "editable": true,
  "location": "/Users/yairchu/dev/marimo/marimo",
  "OS": "Darwin",
  "OS Version": "24.6.0",
  "Processor": "arm",
  "Python Version": "3.12.9",
  "Locale": "en_US",
  "Binaries": {
    "Browser": "140.0.7339.134",
    "Node": "v22.13.0"
  },
  "Dependencies": {
    "click": "8.2.1",
    "docutils": "0.21.2",
    "itsdangerous": "2.2.0",
    "jedi": "0.19.2",
    "markdown": "3.7",
    "narwhals": "2.3.0",
    "packaging": "25.0",
    "psutil": "7.0.0",
    "pygments": "2.19.1",
    "pymdown-extensions": "10.16.1",
    "pyyaml": "6.0.2",
    "starlette": "0.46.1",
    "tomlkit": "0.13.2",
    "typing-extensions": "4.13.2",
    "uvicorn": "0.34.0",
    "websockets": "15.0.1"
  },
  "Optional Dependencies": {
    "loro": "1.5.0",
    "openai": "2.3.0",
    "ruff": "0.14.0"
  },
  "Experimental Flags": {
    "chat_modes": true,
    "multi_column": true,
    "cache_panel": true
  }
}

Code to reproduce

import marimo

__generated_with = "0.17.7"
app = marimo.App(width="full")


@app.cell
def _():
    import marimo as mo
    import matplotlib.pyplot as plt
    return mo, plt


@app.cell
def _(mo, plt):
    _fig = plt.figure()
    plt.plot([1, 2], [3, 2])
    mo.hstack([mo.md("A figure:"), _fig], justify="start")
    return


@app.cell
def _():
    return


if __name__ == "__main__":
    app.run()

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions