Skip to content

Add matplotlib cell magic - #6879

Closed
francisco-dlp wants to merge 3 commits into
ipython:masterfrom
francisco-dlp:Add_matplotlib_cell_magic
Closed

francisco-dlp wants to merge 3 commits into
ipython:masterfrom
francisco-dlp:Add_matplotlib_cell_magic

Conversation

@francisco-dlp

Copy link
Copy Markdown
Contributor

In my workflow I often activate the matplotlib inline backend to execute one cell and I go back to the previous backend afterwards. I use the maplotlib line magic for that but I find that this could be done more conveniently if there was a matplotlib cell magic. This pull request modifies the matplotlib line magic to make it work also as a cell magic.

@takluyver

Copy link
Copy Markdown
Member

See also #6439, which aimed to implement something very similar as a context manager.

@francisco-dlp

Copy link
Copy Markdown
Contributor Author

I was not aware of #6439, thank you.

I was hoping that, because I call enable_matplotlib after run_cell, this implementation won't suffer from the issues that @minrk identified in #6439. However, my implementation doesn't fully work either. It works when temporarily changing to the "inline" backend but, when changing temporarily to the "Qt" backend IPython doesn't create the figure. Here is a notebook to test the feature that highlights the problem.

I guess that this issue could be fixed by calling enable_matplotlib after the cell output has been displayed—what's the proper way of doing this? I have tried using the set_next_input method and it works. However, set_next_input pollutes the notebook with one extra cell every time that the matplotlib magic cell is run.

@ellisonbg

Copy link
Copy Markdown
Member

Even if we can get this working, I am probably -1 on it. It is additional complexity that I think few users will ever use. Adding "Needs Decision" tag so we can make a decision together.

@takluyver

Copy link
Copy Markdown
Member

From the dev meeting last week: we'd prefer this to be a context manager, perhaps even in matplotlib (see e.g. switch_backend()), but enabling and disabling the inline backend may require hooks after the cell's execution, in which case it couldn't be implemented as a context manager, and we'd consider this approach.

However, at this point, we'd like to leave it until after IPython 3.0, which we are trying to get ready for release. Setting the milestone to 4.0.

@takluyver takluyver added this to the 4.0 milestone Jan 26, 2015
@ellisonbg

Copy link
Copy Markdown
Member

This one has sat idle for a while with no activity. Any plans to work on this soon? If not, do you mind if we close this until work starts again - it may be the the work needs to be done in matplotlib as well. We are splitting our repo and all existing PRs are going to bit-rot quickly...

@Carreau

Carreau commented Apr 2, 2015

Copy link
Copy Markdown
Member

I'm closing for inactivity, but did open an Issue reminding us that this was here.

@Carreau Carreau closed this Apr 2, 2015
@francisco-dlp

Copy link
Copy Markdown
Contributor Author

Sorry to be slow to reply. This feature is important for us and we will be
happy to resume work on this in the close future.

2015-04-03 0:29 GMT+02:00 Matthias Bussonnier notifications@github.com:

Closed #6879 #6879.

—
Reply to this email directly or view it on GitHub
#6879 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants