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

use %matplotlib in example notebooks #3683

Merged
merged 7 commits into from Jul 20, 2013
Merged

Conversation

minrk
Copy link
Member

@minrk minrk commented Jul 18, 2013

  • removes any mention of %pylab in our examples
  • adds --matplotlib command-line flag, mapping to the new
  • adds Populated namespace message to %pylab output, at the request of @fperez.
  • fix unicode bug in SVG, discovered during testing

closes #3680
closes #3684

add `Populating namespace` message to `%pylab`

from @fperez
config=True,
help="""Configure matplotlib for interactive use with
the default matplotlib backend."""
)
pylab = CaselessStrEnum(['tk', 'qt', 'wx', 'gtk', 'osx', 'inline', 'auto'],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Want to share the 2 list maybe ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@Carreau
Copy link
Member

Carreau commented Jul 18, 2013

did you removed examples/notebooks/Part 3 - Pylab and Matplotlib.ipynb on purpose ?

just like pylab, but for `enable_matplotlib` instead
minidom.parseString doesn't like unicode objects
prefer `%matplotlib` and explicit imports
@minrk
Copy link
Member Author

minrk commented Jul 18, 2013

Renamed it, forgot to add the renamed notebook. Should be there now.

@Carreau
Copy link
Member

Carreau commented Jul 18, 2013

had a quick read-through. LGTM.

@dpsanders
Copy link
Contributor

OK, seems fine playing around.

You don't want to add just the list of import statements in the pylab docs?

By the way, why is the default inline backend PNG? SVG seems to me to be a much better choice.
(But maybe it's slower to render?)

@dpsanders
Copy link
Contributor

I like the --no-import-all option.
In a way, it would be nice to make that the default, but in the end for interactive use it really is much more practical to import all the names.

@dpsanders
Copy link
Contributor

What about mention of --pylab?
There still seem to be a few of those (if I did the branching right -- still not very secure on that).

@dpsanders
Copy link
Contributor

The main problem is perhaps htmlnotebook.txt, which I am working on rewriting.
Should I do a pull request with the current version?

@minrk
Copy link
Member Author

minrk commented Jul 18, 2013

@dpsanders - it was getting re-wrapped because it was in an argument instead of the main description. It should be more to your taste now:

In [1]: %pylab?
%pylab [--no-import-all] [gui]

Load numpy and matplotlib to work interactively.

This function lets you activate pylab (matplotlib, numpy and
interactive support) at any point during an IPython session.

%pylab makes the following imports::

    import numpy
    import matplotlib
    from matplotlib import pylab, mlab, pyplot
    np = numpy
    plt = pyplot

    from IPython.display import display
    from IPython.core.pylabtools import figsize, getfigs

    from pylab import *
    from numpy import *

If you pass `--no-import-all`, the last to `*` imports will be excluded.

@dpsanders
Copy link
Contributor

Excellent, thanks!
'to' -> 'two' in the last line

from no-import-all description, which gets re-wrapped by argparse.
@minrk
Copy link
Member Author

minrk commented Jul 18, 2013

'to' -> 'two' in the last line

how embarrassing! force-pushed fix, to hide my shame from the git history :)

@dpsanders
Copy link
Contributor

And finally what is the rationale for the pylabtools imports?

By the way, how do you get such nice syntax highlighting...?

@minrk
Copy link
Member Author

minrk commented Jul 18, 2013

And finally what is the rationale for the pylabtools imports?

Backward compatibility. I'm not changing how pylab behaves. I don't remember when or why they were added.

By the way, how do you get such nice syntax highlighting...?

GitHub takes care of that, I just pasted the docstring inside

```python
<paste here>
```

so it treats the whole thing as Python (note how it highlighted any in the body text).

minrk added a commit that referenced this pull request Jul 20, 2013
use `%matplotlib` in example notebooks

- removes any mention of `%pylab` in our examples
- adds `--matplotlib` command-line flag, mapping to the new
- adds `Populated namespace` message to %pylab output, at the request of @fperez.
- fix unicode bug in SVG, discovered during testing

closes #3680
closes #3684
@minrk minrk merged commit 659f35c into ipython:master Jul 20, 2013
@minrk minrk deleted the matplotlib_magic branch July 20, 2013 01:01
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014
use `%matplotlib` in example notebooks

- removes any mention of `%pylab` in our examples
- adds `--matplotlib` command-line flag, mapping to the new
- adds `Populated namespace` message to %pylab output, at the request of @fperez.
- fix unicode bug in SVG, discovered during testing

closes ipython#3680
closes ipython#3684
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bad message when %pylab fails due import *other* than matplotlib --pylab and --matplotlib flag
3 participants