Discussion:
[Matplotlib-users] Python shell despite no IPython problems
Brenton Horne
2015-03-14 09:14:46 UTC
Permalink
Hi,

I am on Windows 7 64 bit SP1 and I installed matplotlib via wheels files
here http://www.lfd.uci.edu/~gohlke/pythonlibs/#matplotlib but now
whenever I execute plotting commands from the python shell (e.g., the
'hi mom' example here
http://matplotlib.org/1.4.3/users/shell.html?highlight=mailing%20list#other-python-interpreters)
it seems like as though some window is trying to pop up but nothing
does. Whereas if I try the the hist example here
(http://matplotlib.org/1.4.3/users/shell.html?highlight=mailing%20list#ipython-to-the-rescue)
in IPython I get a graph pop-up that seems fine.

Thanks for your time,
Brenton
Brenton Horne
2015-03-14 09:17:41 UTC
Permalink
Oh and I have made the mentioned customizations to matplotlibrc
(although the TkAgg line was already present). My python version is
2.7.9 and matplotlib version is 1.4.3.
Post by Brenton Horne
Hi,
I am on Windows 7 64 bit SP1 and I installed matplotlib via wheels
files here http://www.lfd.uci.edu/~gohlke/pythonlibs/#matplotlib but
now whenever I execute plotting commands from the python shell (e.g.,
the 'hi mom' example here
http://matplotlib.org/1.4.3/users/shell.html?highlight=mailing%20list#other-python-interpreters)
it seems like as though some window is trying to pop up but nothing
does. Whereas if I try the the hist example here
(http://matplotlib.org/1.4.3/users/shell.html?highlight=mailing%20list#ipython-to-the-rescue)
in IPython I get a graph pop-up that seems fine.
Thanks for your time,
Brenton
Ryan Nelson
2015-03-14 12:31:21 UTC
Permalink
Sorry Brenton, I meant for my reply to go to the entire list.

Anyway, in your response, I take it that you meant to say that the window
appears and disappears immediately. Yes?

What happens if you restart the Python interpreter and type the following?
Post by Brenton Horne
import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
plt.plot([1,2,3])
plt.show()
Does my first example work fine in the IPython interpreter? (Sorry, I'm not
on my Windows machine right now, so I can't tell you if I'm seeing the same
problem.)

Ryan
Yes, a popup window appears but it appears immediately after it appears.
Brenton,
Unfortunately, those particular examples are out of date. First of all,
I would not recommend using pylab at all -- and I think that many other
folks will give you the same advice. (For reasons that I can describe later
if you are interested.)
IPython is a much different beast than the vanilla Python interpreter,
especially in how it handles GUI stuff. Maybe you could temporarily move
the matplotlibrc file that you created, and try the following from a
Post by Brenton Horne
import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
plt.ion()
plt.plot([1,2,3])
The second line is telling MPL what backend to use. (You can set this in
the rc file later, but let's make sure this isn't the problem for now.) The
third line imports the pyplot module, which is recommended over pylab. The
fourth line is turning on interactive plotting. Once you execute the plot
command on the fifth line, a popup window should appear. Yes?
Ryan
Post by Brenton Horne
Oh and I have made the mentioned customizations to matplotlibrc
(although the TkAgg line was already present). My python version is 2.7.9
and matplotlib version is 1.4.3.
Hi,
I am on Windows 7 64 bit SP1 and I installed matplotlib via wheels files
here http://www.lfd.uci.edu/~gohlke/pythonlibs/#matplotlib but now
whenever I execute plotting commands from the python shell (e.g., the 'hi
mom' example here
http://matplotlib.org/1.4.3/users/shell.html?highlight=mailing%20list#other-python-interpreters)
it seems like as though some window is trying to pop up but nothing does.
Whereas if I try the the hist example here (
http://matplotlib.org/1.4.3/users/shell.html?highlight=mailing%20list#ipython-to-the-rescue)
in IPython I get a graph pop-up that seems fine.
Thanks for your time,
Brenton
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website,
sponsored
by Intel and developed in partnership with Slashdot Media, is your hub
for all
things parallel software development, from weekly thought leadership
blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Matplotlib-users mailing list
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Ryan Nelson
2015-03-14 13:30:51 UTC
Permalink
Brenton,

It's good to know that those other solutions work. Unfortunately, I'm just
sitting down at my Windows 7 computer, and I can't reproduce your problem.
I'm also using the Anaconda Python distribution, which might have different
behavior than your installation method.

However, you're in luck, because there are many, many ways to get IPython
to do what you want. (In fact, anything the Python interpreter does,
IPython does better.) All the possible options, though, can make things a
little tricky... Here's a couple of examples:
C:\> ipython -i filename.py
That will start IPython and automatically load the Python file "filename".
That way anything you define in "filename" will be available in the new
IPython session. Alternatively, you can use the IPython "%run" magic from
inside an IPython session:
In [1]: %run filename.py
That has the same effect as the first example.

As an alternative, IPython notebooks (
http://ipython.org/ipython-doc/stable/notebook/notebook.html) are a very
nice way to interactively work with some data while also retaining all of
the analysis code in a script-like manner. You can have your plots
displayed in the webpage by typing the following in one of the cells:
import matplotlib.pyplot as plt
%matplotlib inline
You can install this using pip:
C:\> pip install ipython[all]

I'm sorry I couldn't help you with your original problem, but I hope these
suggestions help.

Ryan
import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
plt.plot([1,2,3])
plt.show()
That works fine.
And
import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
plt.ion()
plt.plot([1,2,3])
works fine in IPython. I avoid using IPython btw because I don't know how
to call py files from it. When it comes to python commands I like to save
them as py files so I don't have to continually type them out. I know how
to call files in the python shell as I access it via the command prompt
(i.e., by typing python filename.py).
Loading...