ipympl: Images not saved in *.ipynb
Maybe its a design decision, but if I use %matplotlib ipympl
in a notebook, there is no image of plots I’ve made is saved in the *.ipynb file as there was for nbagg
. Thats a huge usability issue for me.
I think the cool thing about notebooks is being able to see the output of your work without having to re-run all the code, some of which may no longer work (data moved etc), so this is a pretty big reversion in functionality for me. It also kills the ability to quickly post onto GitHub or gist, and even save as html no longer has a plot. If this is to replace nbagg
I hope the image saving gets added back in.
Of course, maybe I’m just doing something incorrectly. This was with master on matplotlib and master on ipympl. Jupyter-notebook = 5.0.0
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 11
- Comments: 53 (35 by maintainers)
hey folks, Since this problem is really an issue for me, is anybody working on this? If this is not the case, how could I contribute to this issue? Does someone see a solution but does not have the time for implementing it?
Is there any update to this issue? This majorly undermines the usability of Lab in many cases.
We spent some time with @danallan working on this during the sprints at scipy on saturday.
We have the main pieces together, a hack to make it work without any change in other projects and a longer-term solution requiring some changes in nbconvert and ipywidgets.
Stay tuned.
Just to add I think this is a key usability feature to match the “old” nbagg/notebook backend. Being able to reload an old notebook or see it on a plain html render with a static png is really important. In nbagg, the seamlessness of how it saved the last static render on figure/notebook close was wonderful.
What is the status of this? It appears to be a major regression from
%matplotlib notebook
. If plots aren’t saved in the notebook, it can’t be effectively shared, making it nearly useless. Shouldn’t this be a top priority?I think stop button #176 is already enough as a first step. It would be nice to have it as soon as possible. It is easier to press stop buttons in all figures in a notebook and convert it to html rather than making a screenshot for every plot manually.
This is fixed in #343
Right. I still need to investigate more on this (that is the reason for the PR to still be draft), but I am sure we can find something that will work as intended.
Maybe we can get rid of the close button, and save the image data in the widget model as standard behavior.
Thinking for now only about live usage (not nbconvert) - if the png repr is in there already, could we for example upon opening a new nb filter out unconnected widgets? By definition a dead widget (with no active comm) can’t really do anything useful, so it would seem to me like automatically switching to another repr in the mime bundle is a logical thing to do… No?
@SylvainCorlay do you have any updates on this one? In practice this makes
%matplotlib widget
in JLab a pretty serious usability regression over%matplotlib notebook
in classic…I actually think it’s somewhat connected to #4 - the closing behavior is also different and I wonder if both could be fixed in one shot…
Basically would the following logic be viable?
I’m not switching until
ipympl
has this feature; I’m not sure what the point of a Notebook is without this feature. But I don’t really have any problems with the old notebook backend.Hi @tylerlekang, I plan to implement this feature next week at the Jupyter Widget author workshop.
As of ipywidgets 7.0, widgets become regular output, and the live version will just be an item in the mime bundle.
With the matplotlib widget, we can certainly add an image in the mime bundle for the figure.
At jupytercon next week, we plan on doing some iterations on ipympl.
What would be the the way to save this checkbox state from one Notebook session to the other? Is there a kind-of cookie saved by the widgetsnbextension where I can save its state?
Good point. However, in general, it may be hard to “screenshot” various widgets correctly. I think the best we could do is build an api for asking for an HTML representation of a widget, which is then called recursively from the top-level widget, with perhaps the default giving a div with the width and height of the actual widget.
Perhaps for now, you can see if the matplotlib widget is the top-level widget and do your saving if it is. That might be enough to handle the 80-90% usecase for now. I think it might be a hack right now to see if you are at the top level (we make it easier in the classic notebook by setting a parent attribute on widgets, but something like that isn’t in jlab right now).
Hi, I recently made the conversion from %matplotlib notebook to import ipympl, and have it working well … but am sad to find out there is currently no way to “embed” a static version of whatever figures are in the notebook, for quick and easy viewing on GitHub.
A button with a caption like “embed current figure view as inline PNG” or something to that effect I think is plenty descriptive for users.
Thank you!
@fperez : I agree - notebook is an excellent way to document your work, but to use it as such it must be possible to quickly load the notebook and figures without re-running a possibly time consuming analysis.