TutteInstitute / datamapplot

Creating beautiful plots of data maps
MIT License
784 stars 50 forks source link

InteractiveFigure indefinitely renders as a spinner in Jupyter, exported HTML #43

Closed akshayka closed 1 month ago

akshayka commented 1 month ago

Kudos on the very cool package.

I am attempting the Interactive DataMapPlots tutorial from the documentation in a Jupyter notebook. When I emit the plot as an output, I see a spinner rendering indefinitely:

image

I exported the plot to HTML, and upon opening the HTML file in Chrome I see the same spinner.

In the browser console, I see the following error:

image

Here are some of the packages in my environment and their versions:

datamapplot: 0.4.1
numpy: 2.0.0
ipython: 8.28.0
notebook: 7.2.2

The static plots do work just fine (and look beautiful).

As you can probably guess, I would ultimately love to have DataMapPlot work in marimo notebooks, possibly with metadata about the selected points sent back to Python.

My apologies if this is simple user error.

lmcinnes commented 1 month ago

I don't think it is a user error, but I'll have to see if I can reproduce it.

I did have a plan to allow the output to be an Anywidget with selection indices being a value that get passed back. I don't know much about the details of getting Anywidget working, but my cursory reading through the tutorials made it seem like it was doable for at least a reasonable amount of the functionality. I'm assuming that Anywidget would make things work in Marimo?

The other alternative is that ultimately it is just rendering HTML into an iframe in jupyter (with some munging to work around some of jupyter's quirks. Is there something we could do for marimo that might work similarly?

lmcinnes commented 1 month ago

If the bounds computations happened to end up with np.float32 instead of python floats that would get rendered incorrectly into the HTML. Thanks for finding and reporting this, it's a bit of an embarrassing oversight on my part. Should be fixed now.

akshayka commented 1 month ago

No worries, thank you for the fix!

Yes, we marimo supports anywidget. We can try getting it working through that, and can upstream if we have good results.

akshayka commented 1 month ago

Can confirm that it now works:

image

Thanks for the quick fix.

akshayka commented 1 month ago

@lmcinnes , I'm seeing a similar issue but for plots with selection. Here is an example:

https://colab.research.google.com/drive/14Taj65FefFboB-7Ipi-RAZ1ADVeZWvpc?usp=sharing

pfisterjonas commented 1 month ago

I am still running into this very issue, even with your basic example code. What could be the reason?