473,856 Members | 1,662 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

matplotlib basic question

Hi,

I am exploring the possibility of using python as a replacement of
MATLAB when I leave school. So, I've been playing with matplotlib and
have run into some weird behavior after recently installing python
2.5.1 and matplotlib 0.90 on my Windows XP machine. Here's an example
of what I see:
>>>from matplotlib.pyla b import *
x=arange(-2*pi,2*pi,pi/24)
y=sin(x)
plot(x,y)
[<matplotlib.lin es.Line2D instance at 0x017C38C8>]
>>show()

So, first off, what's up with the [<matplotlib.lin es.Line2D instance
at 0x017C38C8>] line that shows up after my plot command? And second,
when I call show(), a new figure pops up with my sin wave -- seems all
right, yes? But I'm not given another >>prompt in IDLE until or
unless I close the figure that popped up with the show() call.

So, after closing the figure I type this:
>>>show()
plot(x,y)
and this time another figure pops up with my sine wave again and I get
a prompt as well. But now, the figure window is completely
unresponsive -- I can't even close it without getting the "your
program is not repsonding" business. What am I missing? This
behavior so far seems pretty unintuitive.

Any clarification is appreciated!

trevis

Apr 19 '07 #1
12 3444
So, first off, what's up with the [<matplotlib.lin es.Line2D instance
at 0x017C38C8>] line that shows up after my plot command? And second,
when I call show(), a new figure pops up with my sin wave -- seems all
right, yes? But I'm not given another >>prompt in IDLE until or
unless I close the figure that popped up with the show() call.
This may not be strictly correct but thats a reference to the plot
instance which is subsequently passed to show().
If you don't want to see it put a semicolon at the end of your command
eg. plot(range(5));

The issue with IDLE is to due with lack of connection between the
python interpreter event loop and the event loop of matplotlib (I
think). For me the solution was to install the ipython shell (http://
ipython.scipy.o rg/moin/). If you run ipython with the -pylab flag then
you can matplotlib interactively. For example

plot(range(5),' bo')
show()
clf()
plot([1,2,3,4,5],range(0,10,2), 'r-')
(no need for another show() command since the graphics display is
already visible ... unless of course I deleted it in between plot
commands)

hth
Apr 19 '07 #2
On 19 Apr 2007 16:13:43 -0700, cf********@gmai l.com
<cf********@gma il.comwrote:
>
So, first off, what's up with the [<matplotlib.lin es.Line2D instance
at 0x017C38C8>] line that shows up after my plot command? And second,
when I call show(), a new figure pops up with my sin wave -- seems all
right, yes? But I'm not given another >>prompt in IDLE until or
unless I close the figure that popped up with the show() call.
This may not be strictly correct but thats a reference to the plot
instance which is subsequently passed to show().
If you don't want to see it put a semicolon at the end of your command
eg. plot(range(5));
My understanding is that the semicolon trick is specific to IPython,
and does not work in IDLE. I don't know about in other environments.
You can just assign the list of returned plot objects to a variable to
make it invisible at the command line although these return values
(like all return values) are not "shown in the command window" (i.e.
passed to stdout) if they are returned from calls made in a script.
The issue with IDLE is to due with lack of connection between the
python interpreter event loop and the event loop of matplotlib (I
think). For me the solution was to install the ipython shell (http://
ipython.scipy.o rg/moin/). If you run ipython with the -pylab flag then
you can matplotlib interactively. For example

plot(range(5),' bo')
show()
clf()
plot([1,2,3,4,5],range(0,10,2), 'r-')
(no need for another show() command since the graphics display is
already visible ... unless of course I deleted it in between plot
commands)
The OP appears to be using IDLE, for which the things to try are:

In site-packages/matplotlib/backends/backend_tkagg.p y uncomment the
line #os.environ['PYTHONINSPECT'] = '1'

Set interactive=Tru e in share/matplotlib/.matplotlibrc

Start IDLE with the -n flag

In site-packages/matplotlib/backends/backend_tkagg.p y comment out the line

Tk.mainloop()

in the function "show"

-Rob
Apr 20 '07 #3
orangeDinosaur wrote:
Hi,

I am exploring the possibility of using python as a replacement of
MATLAB when I leave school. So, I've been playing with matplotlib and
have run into some weird behavior after recently installing python
2.5.1 and matplotlib 0.90 on my Windows XP machine. Here's an example
of what I see:
>>from matplotlib.pyla b import *
x=arange(-2*pi,2*pi,pi/24)
y=sin(x)
plot(x,y)
[<matplotlib.lin es.Line2D instance at 0x017C38C8>]
>>>show()


So, first off, what's up with the [<matplotlib.lin es.Line2D instance
at 0x017C38C8>] line that shows up after my plot command? And second,
when I call show(), a new figure pops up with my sin wave -- seems all
right, yes? But I'm not given another >>prompt in IDLE until or
unless I close the figure that popped up with the show() call.

So, after closing the figure I type this:
>>>show()
plot(x,y)

and this time another figure pops up with my sine wave again and I get
a prompt as well. But now, the figure window is completely
unresponsive -- I can't even close it without getting the "your
program is not repsonding" business. What am I missing? This
behavior so far seems pretty unintuitive.

Any clarification is appreciated!

trevis
Trevis,

You might look at Numpy, which deals with multi-dimensional arrays.

It has a small matrix component and some progress has been made with
MATLAB amenable problems.

Colin W.

Apr 20 '07 #4
orangeDinosaur <tr**********@g mail.comwrites:
[...] But now, the figure window is completely unresponsive -- I
can't even close it without getting the "your program is not
repsonding" business. What am I missing? This behavior so far
seems pretty unintuitive.
The best way out of this is to use IPython. It also needs a backend
which remains responsive, WxAgg works but Tk did not last time I
tried. IPython 0.8.1 is a release candidate which fixes some Windows
issues in 0.8.0. If you want a stable package that has all the parts
present out of the box then look at Enthought.
--
Pete Forman -./\.- Disclaimer: This post is originated
WesternGeco -./\.- by myself and does not represent
pe*********@wes terngeco.com -./\.- the opinion of Schlumberger or
http://petef.port5.com -./\.- WesternGeco.
Apr 20 '07 #5
OK, I'll go with the enthought installation. This seems to be the
path of least resistance. For those of you who have been in my
position, is there a reason NOT to go with the enthought installation
and do things piecemeal instead?

thanks,
trevis

On Apr 20, 11:36 am, Pete Forman <pete.for...@we sterngeco.comwr ote:
orangeDinosaur <trevis.cr...@g mail.comwrites:
[...] But now, the figure window is completely unresponsive -- I
can't even close it without getting the "your program is not
repsonding" business. What am I missing? This behavior so far
seems pretty unintuitive.

The best way out of this is to use IPython. It also needs a backend
which remains responsive, WxAgg works but Tk did not last time I
tried. IPython 0.8.1 is a release candidate which fixes some Windows
issues in 0.8.0. If you want a stable package that has all the parts
present out of the box then look at Enthought.
--
Pete Forman -./\.- Disclaimer: This post is originated
WesternGeco -./\.- by myself and does not represent
pete.for...@wes terngeco.com -./\.- the opinion of Schlumberger orhttp://petef.port5.com -./\.- WesternGeco.

Apr 20 '07 #6
orangeDinosaur wrote:
OK, I'll go with the enthought installation. This seems to be the
path of least resistance. For those of you who have been in my
position, is there a reason NOT to go with the enthought installation
and do things piecemeal instead?

thanks,
trevis

On Apr 20, 11:36 am, Pete Forman <pete.for...@we sterngeco.comwr ote:
>orangeDinosa ur <trevis.cr...@g mail.comwrites:
> [...] But now, the figure window is completely unresponsive -- I
can't even close it without getting the "your program is not
repsonding" business. What am I missing? This behavior so far
seems pretty unintuitive.

The best way out of this is to use IPython. It also needs a backend
which remains responsive, WxAgg works but Tk did not last time I
tried. IPython 0.8.1 is a release candidate which fixes some Windows
issues in 0.8.0. If you want a stable package that has all the parts
present out of the box then look at Enthought.
--
Pete Forman -./\.- Disclaimer: This post is originated
WesternGeco -./\.- by myself and does not represent
pete.for...@we sterngeco.com -./\.- the opinion of Schlumberger orhttp://petef.port5.com -./\.- WesternGeco.

It's rather heavy and may include stuff you don't need.

I'm not sure that scipy has been updated to Python 2.5

Colin W.

Apr 20 '07 #7
Colin J. Williams wrote:
I'm not sure that scipy has been updated to Python 2.5
? scipy certainly works with 2.5. Are you referring to something else perhaps?

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco

Apr 20 '07 #8
On Apr 20, 2007, at 2:44 PM, Robert Kern wrote:
Colin J. Williams wrote:
>I'm not sure that scipy has been updated to Python 2.5

? scipy certainly works with 2.5. Are you referring to something
else perhaps?
A side question: Is there any plans of updating the scipy.org
Superpack bundle
for Mac OS X to work with 2.5?

Cheers
Tommy
Apr 20 '07 #9
Tommy Grav wrote:
On Apr 20, 2007, at 2:44 PM, Robert Kern wrote:
>Colin J. Williams wrote:
>>I'm not sure that scipy has been updated to Python 2.5
? scipy certainly works with 2.5. Are you referring to something
else perhaps?

A side question: Is there any plans of updating the scipy.org
Superpack bundle
for Mac OS X to work with 2.5?
You would have to ask Chris Fonnesbeck. It's not an "official" binary inasmuch
as scipy has official binaries.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco

Apr 20 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4983
by: Dr. Colombes | last post by:
MatPlotLib question: How to get more different size plot symbols in the plot function ? Is there a way to get different size squares (or circles or triangles, etc.) ? For example, in a two dimensional plot of heights and weights of individuals, is there a way to represent also the age of the individual by the size of the plot symbol ?
4
2259
by: Matt Feinstein | last post by:
Hi all-- I'm planning to try to do a completely local install of matplotlib (in Fedora Core 1)-- the system administrator isn't going to stop me-- but he isn't going to cooperate either. I've got the tarballs for python, numeric, numarray, matplotlib, ipython, wxpython and freetype-- which I think covers the various pre-requisites and post-requisites. One semi-obvious question is where to put the freetype library (the system version in...
8
30489
by: Derek Basch | last post by:
Can anyone give any suggestions on how to make a logarithmic (base 10) x and y axis (loglog) plot in matplotlib? The scatter function doesn't seem to have any log functionality built into it. Thanks, Derek Basch P.S. I suck at math so feel free to make me feel stupid if it is really easy to do :).
0
2608
by: spross | last post by:
hi all i have to use matplotlib on mac os x. on the official site of matplotlib, i found a link to precompiled python packages for mac os x: http://pythonmac.org/packages/py24-fat/index.html so first, i installed python 2.4. that works great! if i type 'python' in the terminal, it loads python 2.4. after that, i loaded and installed the matplotlib package from this
5
11931
by: John Henry | last post by:
I've been asking this question at the matplotlib user list and never gotten an answer. I am hoping that there are matplotlib users here that can help. My problem with matplotlib's way of handling axes label is illustrated by this example: http://www.scipy.org/Cookbook/Matplotlib/MulticoloredLine Notice that the y-axis goes from (-1.1, 1.1) but the first label is at
1
2424
by: redcic | last post by:
I've got a question regarding matplotlib. I use the command: pylab.plot(...) to create a graph. Then, the execution of the code stops after the line: pylab.show() which is off course the last line of my code. My problem is that I have to close the figure window before in order to finish the execution of my code. I'd like to be able to launch my program other times with different
3
4733
by: vajratkarviraj | last post by:
i hav python2.5, matplotlib0.90.1, and py2exe for python 2.5 all on windows xp... i hav a python program(letsc.py) which uses the matplotlib package... and i want 2 make an exe of it for distribution on other comps... i used py2exe... i wrote a setup.py whose contents are : from distutils.core import setup import py2exe import matplotlib setup(console=, options={ 'py2exe': { 'packages' : ,
4
9701
by: John Henry | last post by:
Has anybody been able to create an exe of their python applications involving matplotlib using pyinstall (ver 1.3)? I am getting a: RuntimeError: Could not find the matplotlib data files when I attempt to run the exe created. In searching the web, it appears this is an issue when others tried to use py2exe as well. Unfortunately, the few hits I saw doesn't include enough details to inspire me as to what I should be doing in my
0
4337
by: PamMish1982 | last post by:
Hi all, I have recently started using Python and I am trying to make a GUI out of Tkinter. I am using matplotlib for the graphic purposes. I have to make a exe file from this code. I use py2exe for this purpose but every time I try to make this exe using a setup file I get these errors. Final.py is my python code. Traceback (most recent call last): File "Final.py", line 5, in <module> File "pylab.pyc", line 1, in <module> File...
0
9904
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9758
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11049
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10692
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9527
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5754
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5956
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4169
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3195
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.