-
Notifications
You must be signed in to change notification settings - Fork 217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support interactive plots in CoCalc Jupyter notebooks #1934
Comments
I will be starting implementation of this very soon. |
dup of #1930 |
I don't think this is a dup. Here is the implementation of nbAgg: https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/backends/backend_nbagg.py I've changed the title to interactive plots instead of widgets, too. |
I guess this is really -- make it so
works. It does NOT work yet, because it tries to load some sort of extension that cocalc widgets can't or doesn't support, I guess. So we have widgets, but not enough of widgets... |
This is definitely not supported still. It requires "custom widgets"... |
this came up today in an support email, well, still open. a possible workaround is to use bokeh … but then you have to rewrite a little bit how you code the plots. |
Another workaround might be to use plotly, which also involves rewriting code a bit and has other disadvantages (involving where the code lives). This PR is about adding support for one complicated 3rd party widgets, and as a part of it I've increased the possibility of using others: #5902 As part of that, I'll look into what matplotlib tries to use; maybe it is now easy to support. |
In our current JupyterLab deployment, this happens: %matplotlib notebook
from pylab import *
plot([1,2,7], [2,4,5]) OUTPUT: "Javascript Error: IPython is not defined". I think this means there is some Jupyter classic extension trying to be used. Is there a JupyterLab version of (And wow, evidently I can't copy output from JupyterLab right now. That's a big bug.) |
There is so, maybe it's worth looking into this more modern way instead |
their website is interesting, explains for various online platforms how this backend works: https://matplotlib.org/ipympl/ |
Thanks. The basic process is to find the corresponding npm module, which is: https://www.npmjs.com/package/jupyter-matplotlib install it, hook it into our widget system, and then see all the things that break due to subtle assumptions that might be satisfied in my implementation of ipywidgets (which is in some ways different than the official one), then try to fix those issue. I'll try. |
I also tried installing ipympl and plugging it in as a custom widget into cocalc and it just silently draws an empty canvas. It would be possible to debug, but take quite a while, probably. It's very odd that there are no error messages at all. I suspect it might be much better to invest effort into bqplot than this. That said I've also never used bqplot, since it isn't installed in either our jupyterlab or jupyter classic environments either. I just suspect it might be much better than this, due to many years of serious development at Bloomberg by Sylvaine... |
I just thought about this some more and looked at the javascript source code of this https://github.com/matplotlib/ipympl, and it does have the nice advantage of being typescript, pretty small, and with a significant increase in work on it recently. Also, rendering using canvas instead of png/svg seems pretty cool... Plus full support for matplotlib is of course very nice, given that it is so popular. Also, if they haven't already fixed panning being slow in master, maybe I can fix that sometime. |
Why does this not work with the CoCalc backend? Is it not just displaying some HTML and Javascript? import numpy as np, matplotlib.pyplot as plt
import mpld3
Nxy = (64, 65)
Lxy = (5., 5.)
x, y = np.meshgrid(*(np.arange(_N)*_L/_N - _L/2 for _N, _L in zip(Nxy, Lxy)), indexing='ij', sparse=True)
z = (x+y)*np.exp(-abs(-(x+1j*y))**2)
fig, ax = plt.subplots()
ax.pcolormesh(x.ravel(), y.ravel(), z.T, shading='auto')
ax.set(aspect=1)
mpld3.display() Returns |
I have a related issue running Julia in the CoCalc Jupyter environment. The following code returns an image when run in CoCalc in a Jupyter Lab or Jupyter Classic server, but not in the CoCalc default:
Running it in CoCalc asks me to "Fetch additional ouput" and then gives a |
I think there is no need or reason to support "%matplotlib notebook", which is the ancient deprecated JupyterClassic extension. It's not even supported by JupyterLab (hence Jupyter classic v7+) anymore: So this issue is about support |
|
As of right now, |
Also, ensure "%matplotlib notebook" works, which maybe uses widgets?
WORKAROUND: Use classical Jupyter mode, where widgets are fully supported.
The text was updated successfully, but these errors were encountered: