Skip to content
This repository was archived by the owner on Jul 28, 2025. It is now read-only.
This repository was archived by the owner on Jul 28, 2025. It is now read-only.

plotting fails with document.pyodideMplTarget set #53

@scbarton

Description

@scbarton

I attempted to use document.pyodideMplTarget to set a target element for a plot, and obtained this error message:

  File "<exec>", line 59, in tplot
  File "/lib/python3.11/site-packages/matplotlib/pyplot.py", line 389, in show
    return _get_backend_mod().show(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.11/site-packages/matplotlib_pyodide/html5_canvas_backend.py", line 450, in show
    plt.gcf().canvas.show()
  File "/lib/python3.11/site-packages/matplotlib_pyodide/browser_backend.py", line 117, in show
    div = self._create_root_element()
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.11/site-packages/matplotlib_pyodide/browser_backend.py", line 317, in _create_root_element
    mpl_target.appendChild(div)
    ^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'appendChild'
    M https://cdn.jsdelivr.net/pyodide/v0.25.0/full/pyodide.asm.js:9
    new_error https://cdn.jsdelivr.net/pyodide/v0.25.0/full/pyodide.asm.js:9
    _pythonexc2js https://cdn.jsdelivr.net/pyodide/v0.25.0/full/pyodide.asm.js:9
    callPyObjectKwargs https://cdn.jsdelivr.net/pyodide/v0.25.0/full/pyodide.asm.js:9
    callPyObject https://cdn.jsdelivr.net/pyodide/v0.25.0/full/pyodide.asm.js:9
    apply https://cdn.jsdelivr.net/pyodide/v0.25.0/full/pyodide.asm.js:9
    apply https://cdn.jsdelivr.net/pyodide/v0.25.0/full/pyodide.asm.js:9
    replot http://localhost:8000/lumped_capacitance.html:98
    async* http://localhost:8000/lumped_capacitance.html:103
    EventListener.handleEvent* http://localhost:8000/lumped_capacitance.html:102

I've attached my html code for this error. For now, I'm just using the default append behavior.
lumped_capacitance.html.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions