[Matplotlib-users] plotting problem
Hi All, I have a slight problem using matplotlib 0.87.7. I'm using Ubuntu 6.10 and installed mpl from source. I'm running numpy 1.01, also installed from source. If I run the script below, the first plot shows fine. When I close it the second plot should display but it doesn't. I can only get the first plot to show. Thereafter the plot command doesn't seem to work. I tried reinstalling matplotlib. That didn't work. This works fine if I type it into ipython. It also works on my computer running FC5. Any help will be greatly appreciated. -Ewald # Sample script from pylab import * t = arange(10) f = t*t plot(t,f) show() plot(t,f) show() - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] plotting problem
On 14/02/07, Ewald Zietsman <[EMAIL PROTECTED]> wrote:
> Hi All,
>
> I have a slight problem using matplotlib 0.87.7. I'm using Ubuntu 6.10 and
> installed mpl from source. I'm running numpy 1.01, also installed from
> source.
>
> If I run the script below, the first plot shows fine. When I close it the
> second plot should display but it doesn't. I can only get the first plot to
> show. Thereafter the plot command doesn't seem to work. I tried reinstalling
> matplotlib. That didn't work. This works fine if I type it into ipython. It
> also works on my computer running FC5.
>
> Any help will be greatly appreciated.
>
> -Ewald
>
> # Sample script
> from pylab import *
> t = arange(10)
> f = t*t
> plot(t,f)
> show()
> plot(t,f)
> show()
>
Ewald,
It may be that what you are trying should work.
However, I believe that for interactive work it is recommended to use
ipython -pylab unless you are using the TkAgg backend. You select
this in your matplotlibrc file (it should go into ~/.matplotlib)
OR
(see http://matplotlib.sourceforge.net/faq.html) you can do the use
command before importing pylab, as described at
http://matplotlib.sourceforge.net/backends.html
>>> import matplotlib
>>> matplotlib.use('TkAgg')
>>> from pylab import *
Note that if you are using an IDE like pycrust, ipython -pylab,
pythonwin, or IDLE, pylab may have already been loaded, and subsequent
calls to use or from pylab import * will have no effect unless you
explicitly force a module reload.
HTH. George Nurser.
-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] plotting problem
On Wednesday 14 February 2007 6:59:18 am George Nurser wrote: > On 14/02/07, Ewald Zietsman <[EMAIL PROTECTED]> wrote: > > Hi All, > > > > I have a slight problem using matplotlib 0.87.7. I'm using Ubuntu 6.10 > > and installed mpl from source. I'm running numpy 1.01, also installed > > from source. > > > > If I run the script below, the first plot shows fine. When I close it the > > second plot should display but it doesn't. I can only get the first plot > > to show. Thereafter the plot command doesn't seem to work. I tried > > reinstalling matplotlib. That didn't work. This works fine if I type it > > into ipython. It also works on my computer running FC5. > > > > Any help will be greatly appreciated. > > > > -Ewald > > > > # Sample script > > from pylab import * > > t = arange(10) > > f = t*t > > plot(t,f) > > show() > > plot(t,f) > > show() > > Ewald, > > It may be that what you are trying should work. > > However, I believe that for interactive work it is recommended to use > ipython -pylab unless you are using the TkAgg backend. What Ewald is trying to do used to work. The idea is not to work interactively, but to run a script and have the plots render in stages, the next stage begins when the current windows are closed. I know we have users who take advantage of this behavior for presentations. Darren - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] bug in axis('scaled') in version 0.90 and proposed fix
Eric -
I just installed version 0.90 on my windows machine and it seems that
axis('scaled') doesn't work properly yet.
I thought axis('scaled') will change the axes such that the aspect ratio is
equal WITHOUT changing the limits on the axes.
A simple example shows that this goes wrong (I thought this used to work):
from pylab import *
plot([1,2,3],[1,2,1])
axis([1,2,1,2]) # define new axis limits
axis('scaled')
And now Python comes back with (1.0, 3.0, 0.80004, 2.0), which
are the limits of the original plot command obtained using autoscale_view.
I think this is an easy fix in the axis function of axes.py.
Here you do an autoscale_view, which shouldn't be done in the 'scaled'
option.
I think you only need to change the indicated line below.
Thanks,
Mark
def axis(self, *v, **kwargs):
'''
Convenience method for manipulating the x and y view limits
and the aspect ratio of the plot.
kwargs are passed on to set_xlim and set_ylim -- see their
docstrings for details
'''
if len(v)==1 and is_string_like(v[0]):
s = v[0].lower()
if s=='on': self.set_axis_on()
elif s=='off': self.set_axis_off()
elif s in ('equal', 'tight', 'scaled', 'normal', 'auto',
'image'):
self.set_autoscale_on(True)
self.set_aspect('auto')
if s!= 'scaled': self.autoscale_view() # THIS LINE WAS
CHANGED BY ADDING THE IF STATEMENT
self.apply_aspect()
if s=='equal':
self.set_aspect('equal', adjustable='datalim')
elif s == 'scaled':
self.set_aspect('equal', adjustable='box', anchor='C')
self.set_autoscale_on(False) # Req. by Mark Bakker
elif s=='tight':
self.autoscale_view(tight=True)
self.set_autoscale_on(False)
elif s == 'image':
self.autoscale_view(tight=True)
self.set_autoscale_on(False)
self.set_aspect('equal', adjustable='box', anchor='C')
-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] bug in axis('scaled') in version 0.90 and proposed fix
I have a follow-up on my previous emai.
I don't think we should do an autoscale_view() for axis('equal') either.
For axis('equal') only the limits of either the x or y axis are adjusted
(enlarged really) until the aspect ratio is equal.
Not sure about the others. Do we ever need to do it?
Mark
-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Mlib and GUI not refreshing
Hello, I have been working with Mlib and networkX to create a server which listens for connections and based on the message it receives, it updates and shows a graph. These are great tools but one thing has come up: when the graph has been updated and the control goes back so listening socket.accept(), the GUI does not refresh anymore. This means that the whole GUI turns into gray if some other window is brought on top of it. Also it isn't possible to close the GUI window from the 'X' button etc. However, when a new message arrives to the server, the GUI is updated but then the refreshes are left undone until the next message and this cycle repeats over and over. If I change my program so that after the first draw & show the program runs exit, the GUI is refreshed all the time and thus works like it should. Any suggestions? I found out that someone else had the same problem: http://article.gmane.org/gmane.comp.python.matplotlib.general/5550/match=ipython+gui+refresh My system is FC4 with networkX-0.33, Mlib-0.90.0, python 2.4.3, ipython 0.7.2. I have tried TkAgg, GTKAgg and WxAgg but they all give the same result. With GTK backend even the graph doesn't show up so. Maybe ipython has something to do with this? My program doesn't have a proper GUI so only the graph is shown graphically. That is why I haven't looked at embedding Mlib stuff. Here are two simple examples how the problem could be reproduced. The window is not refreshed until the sleep has run out. 1) import networkx as NX import pylab as P import time G=NX.Graph() G.add_edge(1,2) G.add_edge(2,3) NX.draw(G) time.sleep(5) 2) from pylab import * import time gcf().text(0.5, 0.95, 'Distance Histograms by Category is a really long title') show() time.sleep(5) Thanks for any answers or suggestions! Tomi Hautakoski [EMAIL PROTECTED] When I play in the sandbox, the cat covers me up! - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] matplotlib and boa
> I've been trying to use matplotlib from boa constructor (on windows,
> running enthon-python2.4-1.0.0 and boa-constructor 0.4.4). For test
> purpose I have a single button-event call this function:
>
> def testPlot():
> plot([1,2,3])
> show()
>
> Everything is fine for the first event - button fires the function and
> a plot-window is showing. Killing this window and have a second go at
> the plot at first seems to work but the window can not be closed and
> when I try to move said window the whole application crash.
There is a conflict between the GUI library used by boa constructor
(wxWidgets/wxPython) and the one used by default by matplotlib when
you run the show() command (Tk).
Each of these two libraries run an event loop, handling all your
keyboard and mouse inputs. When you start your application, wxWidgets
has control. When you run show(), Tk takes control and displays your
matplotlib chart. But when you close the chart window, Tk keeps
control, so your application freezes.
The solution is to use another backend, compatible with wxpython. Try
backend WX or WXAgg.
At the top of your script (before import pylab), add this:
import matplotlib
matplotlib.use('WX')
or:
import matplotlib
matplotlib.use('WXAgg')
More explanations here: http://matplotlib.sourceforge.net/backends.html
For reference, here is information provided on matplotlib's web site:
http://matplotlib.sourceforge.net/installing.html
There are known conflicts with some of the backends with some python
IDEs such as pycrust, idle. If you want to use matplotlib from an IDE,
please consult backends for compatibility information. You will have
the greatest likelihood of success if you run the examples from the
command shell or by double clicking on them, rather than from an IDE.
If you are interactively generating plots, your best bet is TkAgg from
the standard python shell or ipython.
Good luck!
-- Nicolas Grilly
-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Toggle plot trace
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hello, I'm working on a GUI with wxPython to display several traces of data. Using a checkbox, I would like to be able to turn traces on the plot on and off. I have managed to find the right methods to turn the whole axes on and off, but not individual traces. Any help would be appreciated. Thanks, Dave - -- David D. Clark Electrical Engineer P-23, Neutron Science and Technology e-mail mailto:[EMAIL PROTECTED] GPG Public key 0x018D6523 available at http://www.us.pgp.net http://www.gnupg.org has information about public key cryptography -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.5 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFF0zh9Nu7GcwGNZSMRAgw3AKCuak5AJhp9df71nbZ+/QDDZc86OQCdHVBA YRXrvtwMQqObyfFA08NKIBw= =2Th4 -END PGP SIGNATURE- - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] testing of matplotlib 0.90 - on Win XP and Python 2.5
I just downloaded the 0.9 binary and did some testing and also updated all the wx examples to use the new wx namespace (i.e. change from "from wxPython.wx import *" to "import wx". dynamic_demo_wx.py - changed name space using Boa's conversion tool - moved the timer stuff to __init__, saved a reference and stop the timer on close, so that this shuts down correctly. dynamic_demo_wxagg2.py - changed name space using Boa's conversion tool - complains about wxmsw26uh_vc.dll, but runs if one clicks on OK dynamic_demo_wxagg.py - changed name space using Boa's conversion tool - complains about wxmsw26uh_vc.dll, but runs if one clicks on OK embedding_in_wx.py - changed name space using Boa's conversion tool - screen update/refresh is for some reason very slow embedding_in_wx2.py - changed name space using Boa's conversion tool - complains about wxmsw26uh_vc.dll, but runs if one clicks on OK embedding_in_wx3.py - changed name space using Boa's conversion tool - manually made changes regarding XRC as it is not handled by the conversion tool - can't get it to work, as think it is because "data/embedding_in_wx3.xrc" is not found - it is not included in the zip?! embedding_in_wx4.py - changed name space using Boa's conversion tool - complains about wxmsw26uh_vc.dll, but runs if one clicks on OK simple3d_oo.py - changed name space using Boa's conversion tool - complains about wxmsw26uh_vc.dll, but runs if one clicks on OK If someone could take the enclosed and maybe create an updated examples.zip When a build for wxPython 2.8 is available I will do some more testing, especially with regards to py2exe packaging. Werner dynamic_demo_wx.py Description: application/python dynamic_image_wxagg2.py Description: application/python dynamic_image_wxagg.py Description: application/python embedding_in_wx.py Description: application/python embedding_in_wx2.py Description: application/python embedding_in_wx4.py Description: application/python simple3d_oo.py Description: application/python - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] get_gridlines
Hi list, The tutorial indicated that I can use gca to get at the grid by doing a: glines = getp(gca(), 'gridlines') but when I do that, I get a "Subplot instance has no attribute "get_gridlines". How do I get to the grid object? Thanks, -- John Henry - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] get_xgridlines (was get_gridlines)
Okay, I'll answer my own question. After looking through the code, it appears I have to do a xgridlines - not gridlines, like: glines = getp(gca(), 'xgridlines') > > Hi list, > > The tutorial indicated that I can use gca to get at the grid > by doing a: > > glines = getp(gca(), 'gridlines') > but when I do that, I get a "Subplot instance has no > attribute "get_gridlines". > > How do I get to the grid object? > > Thanks, > > -- > John Henry -- John Henry - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] test message
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 - -- David D. Clark Electrical Engineer P-23, Neutron Science and Technology e-mail mailto:[EMAIL PROTECTED] GPG Public key 0x018D6523 available at http://www.us.pgp.net http://www.gnupg.org has information about public key cryptography -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.5 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFF01UANu7GcwGNZSMRAoXAAKCXUTOg6rJQ+/uWpA9+y9lMvXjDcACgj2Qh fVgbxatBaf5cT8GsNc3eB70= =8ZDP -END PGP SIGNATURE- - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] matplotlib and boa
Hi,
Thank's a lot for your informative answer. I've solved the issue now using
WXAgg as backend. WX was way too slow (plotting two graphs with 8000
datapoints each)
regards,
Sture
>> I've been trying to use matplotlib from boa constructor (on windows,
>> running enthon-python2.4-1.0.0 and boa-constructor 0.4.4). For test
>> purpose I have a single button-event call this function:
>>
>> def testPlot():
>> plot([1,2,3])
>> show()
>>
>> Everything is fine for the first event - button fires the function and
>> a plot-window is showing. Killing this window and have a second go at
>> the plot at first seems to work but the window can not be closed and
>> when I try to move said window the whole application crash.
>
> There is a conflict between the GUI library used by boa constructor
> (wxWidgets/wxPython) and the one used by default by matplotlib when
> you run the show() command (Tk).
>
> Each of these two libraries run an event loop, handling all your
> keyboard and mouse inputs. When you start your application, wxWidgets
> has control. When you run show(), Tk takes control and displays your
> matplotlib chart. But when you close the chart window, Tk keeps
> control, so your application freezes.
>
> The solution is to use another backend, compatible with wxpython. Try
> backend WX or WXAgg.
>
> At the top of your script (before import pylab), add this:
> import matplotlib
> matplotlib.use('WX')
>
> or:
> import matplotlib
> matplotlib.use('WXAgg')
>
> More explanations here: http://matplotlib.sourceforge.net/backends.html
>
> For reference, here is information provided on matplotlib's web site:
> http://matplotlib.sourceforge.net/installing.html
> There are known conflicts with some of the backends with some python
> IDEs such as pycrust, idle. If you want to use matplotlib from an IDE,
> please consult backends for compatibility information. You will have
> the greatest likelihood of success if you run the examples from the
> command shell or by double clicking on them, rather than from an IDE.
> If you are interactively generating plots, your best bet is TkAgg from
> the standard python shell or ipython.
>
> Good luck!
>
> -- Nicolas Grilly
>
>
--
Sture Lygren
Computer Systems Administrator
Andoya Rocket Range
Work: +4776144451 / Fax: +4776144401
-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] matplotlib and boa
On 2/14/07, Sture Lygren <[EMAIL PROTECTED]> wrote: > Thank's a lot for your informative answer. I've solved the issue now using > WXAgg as backend. WX was way too slow (plotting two graphs with 8000 > datapoints each) Happy to know it have solved your issue :-) NG - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Toggle plot trace
On 2/14/07, David Clark (Lists) <[EMAIL PROTECTED]> wrote: > I'm working on a GUI with wxPython to display several traces of data. > Using a checkbox, I would like to be able to turn traces on the plot on > and off. I have managed to find the right methods to turn the whole > axes on and off, but not individual traces. Any help would be appreciated. Everythong that draws into a figure (Axes, Text, Line2D, Polygon, etc...) all derive from Artist which has a visible property. So you can turn anything off/on with o.set_visible(True|False) JDH - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] plotting problem
On 2/14/07, Darren Dale <[EMAIL PROTECTED]> wrote: > What Ewald is trying to do used to work. The idea is not to work > interactively, but to run a script and have the plots render in stages, the > next stage begins when the current windows are closed. I know we have users > who take advantage of this behavior for presentations. This was always an unsupported use of show. The FAQ entry http://matplotlib.sourceforge.net/faq.html#SHOW states in bold: IMPORTANT: show should called at most once per script and it should be the last line of your script. At that point, the GUI takes control of the interpreter. If you want to force a figure draw, use draw instead. That is worked in some cases can be considered an accident of the backend and possibly GUI version. That said, I would like to support this use case, essentially a pause until some user input is given. Lots of people want it and it is a useful thing. This came up again back in October. Nadia at STScI worked on this and I think she thought she had a solution for blocking calls in a threaded environment. Maybe she can provide some input here. JDH - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] testing of matplotlib 0.90 - on Win XP and Python 2.5
Thanks for doing this, the wx back-ends are a bit neglected at the moment. Which version of wxPython did you test this all on? We really need some work/testing with 2.8.*, I now there are some issues on OS-X, but I haven't tried it anywhere else yet. -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R(206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception [EMAIL PROTECTED] - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV ___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] bug in axis('scaled') in version 0.90 and proposed fix
Mark,
It sounds like what you want axis('scaled') to do is nothing other than
gca().set_aspect(1, adjustable='box')
draw_if_interactive()
I think this is a bit out of character with things like axis('equal').
Part of this character is that automatic things are turned on, so that
going back and forth between axis('equal') and axis('scaled') switches
back and forth between the same two plots; the result is not
history-dependent.
At your request (between the 0.87.7 and 0.90 releases), I put in a
little bit of history-dependence by making axis('scaled') call to
self.set_autoscale_on(False) # Req. by Mark Bakker
after the set_aspect() call. This means that you can get the behavior
you want simply by changing your example to
from pylab import *
plot([1,2,3],[1,2,1])
axis('scaled')
axis([1,2,1,2]) # define new axis limits
Is this good enough? Do you really need to be able to set the axis
limits *before* the call to axis('scaled')? If so, then I am inclined
to make this a separate option for the axis command, because I think the
present behavior of axis('scaled') is sensible in the context of the
other existing options.
Eric
Mark Bakker wrote:
> Eric -
>
> I just installed version 0.90 on my windows machine and it seems that
> axis('scaled') doesn't work properly yet.
> I thought axis('scaled') will change the axes such that the aspect ratio
> is equal WITHOUT changing the limits on the axes.
> A simple example shows that this goes wrong (I thought this used to work):
>
> from pylab import *
> plot([1,2,3],[1,2,1])
> axis([1,2,1,2]) # define new axis limits
> axis('scaled')
>
> And now Python comes back with ( 1.0, 3.0, 0.80004, 2.0),
> which are the limits of the original plot command obtained using
> autoscale_view.
> I think this is an easy fix in the axis function of axes.py.
> Here you do an autoscale_view, which shouldn't be done in the 'scaled'
> option.
> I think you only need to change the indicated line below.
>
> Thanks,
>
> Mark
>
> def axis(self, *v, **kwargs):
> '''
> Convenience method for manipulating the x and y view limits
> and the aspect ratio of the plot.
>
> kwargs are passed on to set_xlim and set_ylim -- see their
> docstrings for details
> '''
> if len(v)==1 and is_string_like(v[0]):
> s = v[0].lower()
> if s=='on': self.set_axis_on()
> elif s=='off': self.set_axis_off()
> elif s in ('equal', 'tight', 'scaled', 'normal', 'auto',
> 'image'):
> self.set_autoscale_on(True)
> self.set_aspect('auto')
> if s!= 'scaled': self.autoscale_view() # THIS LINE WAS
> CHANGED BY ADDING THE IF STATEMENT
> self.apply_aspect()
> if s=='equal':
> self.set_aspect('equal', adjustable='datalim')
> elif s == 'scaled':
> self.set_aspect ('equal', adjustable='box', anchor='C')
> self.set_autoscale_on(False) # Req. by Mark Bakker
> elif s=='tight':
> self.autoscale_view (tight=True)
> self.set_autoscale_on(False)
> elif s == 'image':
> self.autoscale_view(tight=True)
> self.set_autoscale_on(False)
> self.set_aspect('equal', adjustable='box', anchor='C')
>
>
>
>
>
> -
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
>
>
>
>
> ___
> Matplotlib-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] UnboundLocalError from multiple traces with plot_date in 0.90
I'm back to developing with matplotlib after a bit of a hiatus. I am refactoring an app I wrote about two years ago. I suspect I have uncovered a bug in 0.90 which was not present in 0.87.7. The small test script, which I created to reproduce the problem, fails with the follow traceback in 0.90: [EMAIL PROTECTED]:$ python debug.py Traceback (most recent call last): File "debug.py", line 43, in ? plot_date(jt2, f2, ':') File "/usr/lib/python2.4/site-packages/matplotlib/pylab.py", line 2064, in plot_date ret = gca().plot_date(*args, **kwargs) File "/usr/lib/python2.4/site-packages/matplotlib/axes.py", line 2395, in plot_date self.xaxis_date(tz) File "/usr/lib/python2.4/site-packages/matplotlib/axes.py", line 1564, in xaxis_date formatter = AutoDateFormatter(locator) UnboundLocalError: local variable 'locator' referenced before assignment but running in 0.87.7 produces a figure with two traces. If only one trace is done, 0.90 produces a figure. I can drop back to 0.87.7 but I would prefer to continue working with 0.90. Glad to be back using Python and matplotlib! I'm running on Debian Etch on both machines. 0.90 is compiled from the latest tarball since Etch only has 0.87.7 available. Delbert debug.zpi Description: Zip archive - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV___ Matplotlib-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/matplotlib-users
