pyodide / matplotlib-pyodide

HTML5 backends for Matplotlib compatible with Pyodide
Mozilla Public License 2.0
33 stars 9 forks source link

Matplotlib does not work #7

Open Martmists-GH opened 2 years ago

Martmists-GH commented 2 years ago

🐛 Bug

Matplotlib does not render plots

To Reproduce

  1. go to https://pyodide.org/en/latest/console.html
  2. run the following:
>>> import matplotlib.pyplot as plt
>>> import numpy as np
>>> plt.plot(np.sin(np.linspace(0, 0.05, 200) * np.pi * 2 * 100))
[<matplotlib.lines.Line2D object at 0x1fc7878>]
>>> plt.show()
>>>

Expected behavior

The plot shows up, either inline or as popup

Environment

oeway commented 2 years ago

The console does not support that, you should use for example: JupyterLite.

Martmists-GH commented 2 years ago

I'd prefer not to use jupyter for embedding though

rth commented 2 years ago

I agree we should add an example with matplotlib (related pyodide/pyodide#1498 ).

Adding support for matplotlib to the REPL is another matter, personally, I don't think it would be in the scope of Pyodide (unless someone can demonstrate that it would be very easy to do). We would rather keep the REPL simple, and leave this work to other projects.

hoodmane commented 2 years ago

I think it could be fun to have a more fully featured repl at some point, maybe in a separate repo inside of the pyodide org. But yeah, console.html shouldn't get very complicated. I think that jqueryterminal does have support for echoing html and will render it in a reasonable way, so it is possible that this could be done without too much extra complexity.