Skip to content
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

Notebook backend: possible to remove javascript/html when figure is closed? #5219

Closed
jorisvandenbossche opened this issue Oct 10, 2015 · 1 comment

Comments

@jorisvandenbossche
Copy link

Using the notebook backend with %matplotlib notebook stores several outputs in the ipynb file: both javascript code and a png figure embedded in a html data object.
When you close a figure in the notebook, the interactive figure is replaced by a static image, and then seems to the user similar as to using %matplotlib inline (apart from the default resolution). But, in the notebook file itself, it still is a javascript + html output and not a png image as with the inline backend.

I was wondering if it would be possible/desirable to also have the data that is stored in the notebook file be converted to a 'real' image ("image/png") when the figure is closed.
This question comes from two drawbacks I noticed with the current situation when using %matplotlib notebook:

  • The javascript 'clutters' the notebook file: the notebook format is already not friendly to diffs, but this makes it even more difficult (the javascript takes a lot of lines, while the image itself is only 1 line). Once, the figure is closed, I don't think the javascript is still useful?
  • Figures that are created with the notebook backend will not be visible for untrusted notebooks (so eg every notebook that you get from somebody else has first be trusted before you can see the figures in the notebook)

Note: I am not familiar with the backend stuff and the ipython comms, so I don't know this is even possible.

@tacaswell tacaswell added this to the proposed next point release (2.1) milestone Oct 10, 2015
@tacaswell tacaswell modified the milestones: next bug fix release (2.0.1), proposed next point release (2.1) Oct 10, 2015
@tacaswell
Copy link
Member

The logic of replacing interactive figure with a static figure happens here.

It looks like that is only touching the DOM on the browser side so I am not really clear how that get reflected back to the IPython notebook side.

Some of this may get better when we replace nbagg with something based directly in IPython widgets, rather than injecting our own divs.

attn @pelson @blink1073

@QuLogic QuLogic modified the milestones: 2.1 (next point release), 2.0.1 (next bug fix release) May 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants