Re: [Matplotlib-users] Event errors in qt5 backend after recent commit

2015-02-19 Thread Jorge Scandaliaris
Thomas Caswell tcaswell@... writes:

 
 
 Jorge,I have put in a PR to fix this issue.  Can you confirm that it is
equivalent to your fix?  For aesthetic reasons I chose to pass guiEvent as a
kwarg to all of the event related functions.
 
 https://github.com/matplotlib/matplotlib/pull/4130
 
 
 Tom

I can confirm this fixes the issue I had. 

Jorge
--
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration  more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631iu=/4140/ostg.clktrk
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Event errors in qt5 backend after recent commit

2015-02-18 Thread Jorge Scandaliaris
Hi,
A recent commit against lib/matplotlib/backends/backend_qt5.py [1] causes
some errors in code that was working fine before. The error is as follows: 

---
TypeError Traceback (most recent call last)
/home/jscandal/sw/matplotlib/matplotlib.py3/lib/matplotlib/backends
/backend_qt5.py
in enterEvent(self, event)
249 
250 def enterEvent(self, event):
-- 251 FigureCanvasBase.enter_notify_event(self, event, guiEvent=event)
252 
253 def leaveEvent(self, event):

TypeError: enter_notify_event() got multiple values for argument 'guiEvent'

---
TypeError Traceback (most recent call last)
/home/jscandal/sw/matplotlib/matplotlib.py3/lib/matplotlib/backends
/backend_qt5.py
in leaveEvent(self, event)
253 def leaveEvent(self, event):
254 QtWidgets.QApplication.restoreOverrideCursor()
-- 255 FigureCanvasBase.leave_notify_event(self, event, guiEvent=event)
256 
257 def mousePressEvent(self, event):

TypeError: leave_notify_event() got multiple values for argument 'guiEvent'



Reverting the changes introduced by the commit in lines 251 and 255 of
backend_qt5.py seems to fix the issue, in my particular use case.

Regards,

Jorge


1.
b72e0cd9e63f7cf4bec2908143c62c23666b674a
Author: Steven Silvester steven.silves...@ieee.org
Date:   Sun Feb 15 09:38:21 2015 -0600

Add guiEvent data to Qt backend



--
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration  more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631iu=/4140/ostg.clktrk
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Qt4Agg backend possible bug

2014-06-05 Thread Jorge Scandaliaris
Hi,
I just mentioned this problem with Qt4Agg and python 3.4 in another thread
[1], but I decided to post it on a thread of its own, as I suspect it might
be a bug in the Qt4Agg backend.

I get a NameError exception (see backtrace below) when trying to use key
events in matplotlib (master branch rev:
e322d5f5bb024bbec44d3ba76da1bc16bf52af9c), python 3.4.1, and pyqt 4.10.
Is this a bug?

Regards,

Jorge


backtrace:
---
NameError Traceback (most recent call last)
/home/jscandal/sw/matplotlib/matplotlib/lib/matplotlib/backends/backend_qt4.py
in
keyReleaseEvent(self=matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg
object, event=PyQt4.QtGui.QKeyEvent object)
308 
309 def keyReleaseEvent(self, event):
-- 310 key = self._get_key(event)
key = undefined
self._get_key = bound method FigureCanvasQTAgg._get_key of
matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg object at 0x7f0393412948
event = PyQt4.QtGui.QKeyEvent object at 0x7f0393507a68
311 if key is None:
312 return

/home/jscandal/sw/matplotlib/matplotlib/lib/matplotlib/backends/backend_qt4.py
in _get_key(self=matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg
object, event=PyQt4.QtGui.QKeyEvent object)
363 return None
364 
-- 365 key = unichr(event_key)
key = undefined
global unichr = undefined
global event_key = undefined
366 # qt delivers capitalized letters.  fix capitalization
367 # note that capslock is ignored

NameError: name 'unichr' is not defined





[1] http://thread.gmane.org/gmane.comp.python.matplotlib.general/34361


--
Learn Graph Databases - Download FREE O'Reilly Book
Graph Databases is the definitive new guide to graph databases and their 
applications. Written by three acclaimed leaders in the field, 
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] What backends are working with python 3

2014-06-05 Thread Jorge Scandaliaris
Werner wernerfbd@... writes:

...
 Some time ago I did a bit of work on the wx backend to work with 
 wxPython Phoenix.
 
 https://github.com/matplotlib/matplotlib/pull/2803
 
 I haven't had time to look at the last few comments made on that PR.
 
 Just the other day someone contacted me off list and he used it on a 
 project of his with a recent build of Phoenix.  He noted small refresh 
 issues which corrected itself by resizing the frame, this probably needs 
 a self.Refresh or similar when things get drawn.
 
 Builds for Phoenix are here:
 http://wxpython.org/Phoenix/snapshot-builds/
 
 Recent versions of Phoenix (this is still in development) run on Py 2.7, 
 Py 3.3 and Py 3.4 and use the wheel format and can be installed with the 
 following at least on Windows and Mac as far as I know:
 
 pip install -U --pre -f http://wxpython.org/Phoenix/snapshot-builds/ 
 wxPython_Phoenix
 
 Werner
 
 

Thanks for the info, but at this point I'd rather focus on the task I need
to solve rather than in the necessary tools. I have just creted a new thread
regarding the Qt4Agg backend problem I saw, as that is probably the closest
path to have a working setup. If that can't be solved, I have to probably go
back to python 2. I upgraded in the first place because it seemed like all
the tools were ready, and that's a natural path, but I can live with python
2 for a bit longer...

Jorge


--
Learn Graph Databases - Download FREE O'Reilly Book
Graph Databases is the definitive new guide to graph databases and their 
applications. Written by three acclaimed leaders in the field, 
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Qt4Agg backend possible bug

2014-06-05 Thread Jorge Scandaliaris
Jorge Scandaliaris jorgesmbox-ml@... writes:

 
 Hi,
 I just mentioned this problem with Qt4Agg and python 3.4 in another thread
 [1], but I decided to post it on a thread of its own, as I suspect it might
 be a bug in the Qt4Agg backend.
 
 I get a NameError exception (see backtrace below) when trying to use key
 events in matplotlib (master branch rev:
 e322d5f5bb024bbec44d3ba76da1bc16bf52af9c), python 3.4.1, and pyqt 4.10.
 Is this a bug?

I can confirm that using chr() instead of unichr() fixes this problem. I
don't know how ones handle python2 vs python3 in these cases

diff --git a/lib/matplotlib/backends/backend_qt4.py
b/lib/matplotlib/backends/backend_qt4.py
index 70152aa..b0d8233 100644
--- a/lib/matplotlib/backends/backend_qt4.py
+++ b/lib/matplotlib/backends/backend_qt4.py
@@ -362,7 +362,7 @@ class FigureCanvasQT(QtGui.QWidget, FigureCanvasBase):
 if event_key  MAX_UNICODE:
 return None
 
-key = unichr(event_key)
+key = chr(event_key)
 # qt delivers capitalized letters.  fix capitalization
 # note that capslock is ignored
 if 'shift' in mods:

jorge



--
Learn Graph Databases - Download FREE O'Reilly Book
Graph Databases is the definitive new guide to graph databases and their 
applications. Written by three acclaimed leaders in the field, 
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Qt4Agg backend possible bug

2014-06-05 Thread Jorge Scandaliaris
Jorge Scandaliaris jorgesmbox-ml@... writes:

 
 Hi,
 I just mentioned this problem with Qt4Agg and python 3.4 in another thread
 [1], but I decided to post it on a thread of its own, as I suspect it might
 be a bug in the Qt4Agg backend.
 
 I get a NameError exception (see backtrace below) when trying to use key
 events in matplotlib (master branch rev:
 e322d5f5bb024bbec44d3ba76da1bc16bf52af9c), python 3.4.1, and pyqt 4.10.
 Is this a bug?
 


A trivial fix using six (credits to Werner for suggesting it), also
submitted as issue #3117 in the GH tracker:

diff --git a/lib/matplotlib/backends/backend_qt4.py
b/lib/matplotlib/backends/backend_qt4.py
index 70152aa..26486b4 100644
--- a/lib/matplotlib/backends/backend_qt4.py
+++ b/lib/matplotlib/backends/backend_qt4.py
@@ -362,7 +362,7 @@ class FigureCanvasQT(QtGui.QWidget, FigureCanvasBase):
 if event_key  MAX_UNICODE:
 return None

-key = unichr(event_key)
+key = six.unichr(event_key)
 # qt delivers capitalized letters.  fix capitalization
 # note that capslock is ignored
 if 'shift' in mods:



--
Learn Graph Databases - Download FREE O'Reilly Book
Graph Databases is the definitive new guide to graph databases and their 
applications. Written by three acclaimed leaders in the field, 
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] What backends are working with python 3

2014-06-04 Thread Jorge Scandaliaris
Hi,
After a while away from matplotlib I am back working on some old code. I
decided to switch to python 3 (bad idea?) and I am having problems with
backends. I used to use GTKAgg, it worked ok, but it doesn't seem to work
with python 3?
1- What are my choices running python 3 and matplotlib from source (I
started following the master branch to avoid some bugs in the past, and kept
using it since)? I did look in the docs and searched the lists, but I
couldn't find a clear answer.
2- Is it discouraged to use matplotlib with python 3?
3- I got the Qt4Agg backend sort of working. It displays my figures ok, but
throws exceptions related to some key events I have set up. See below for
backtrace. unichr() has disappeared in python 3, but somehow the backend is
still using it?

Sorry about the post becoming a bit messy. 

Jorge

backtrace:

NameError Traceback (most recent call last)
/home/jscandal/sw/matplotlib/matplotlib/lib/matplotlib/backends/backend_qt4.py
in
keyReleaseEvent(self=matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg
object, event=PyQt4.QtGui.QKeyEvent object)
308 
309 def keyReleaseEvent(self, event):
-- 310 key = self._get_key(event)
key = undefined
self._get_key = bound method FigureCanvasQTAgg._get_key of
matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg object at 0x7fc124046af8
event = PyQt4.QtGui.QKeyEvent object at 0x7fc1260cfb88
311 if key is None:
312 return

/home/jscandal/sw/matplotlib/matplotlib/lib/matplotlib/backends/backend_qt4.py
in _get_key(self=matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg
object, event=PyQt4.QtGui.QKeyEvent object)
363 return None
364 
-- 365 key = unichr(event_key)
key = undefined
global unichr = undefined
global event_key = undefined
366 # qt delivers capitalized letters.  fix capitalization
367 # note that capslock is ignored

NameError: name 'unichr' is not defined



--
Learn Graph Databases - Download FREE O'Reilly Book
Graph Databases is the definitive new guide to graph databases and their 
applications. Written by three acclaimed leaders in the field, 
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Event handling... again

2012-07-04 Thread Jorge Scandaliaris
Hi,
Are there any caveats when using events together with IPython that you
are aware of? I have some code that I use to interactively explore
images that works OK when run from a Python interpreter but does not
(see note) when run from IPython. With --pylab option the problems are
more evident, but don't disappear completely without it. If I test
with some of the examples (i.e.
http://matplotlib.sourceforge.net/examples/event_handling/data_browser.html),
they work OK in both cases. I can't really post a working example, as
my code has grown large, and I am still trying to pin point the root
cause. I am posting also at the IPython ml, who knows

I'll appreciate any hints and or related problems you might have had,
that help me find a solution to this.

Jorge


Note: Does not run refers to *some* of the event handling defined not
working, for example I have defined specific keys that trigger the
loading of a new image

--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Event handling... again

2012-07-04 Thread Jorge Scandaliaris
 De: Tony Yu tsy...@gmail.com


Just a wild guess: Any chance you're using some GUI-toolkit-specific 
functionality?




Can you elaborate please? I use the GTKAgg backend, and I guess IPython has 
specific mechanisms (I don't know the details) for keeping both the plot and 
the interpreter responsive, that's the --pylab option I mention. However, why 
am I the only asking for help here? Is it that just a few people use events and 
gtk backend and IPython?
My script, although larger and by now more complex, follows the lines of the 
example I gave earlier...

Jorge

--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Has nxutils been removed from mpl?

2012-03-08 Thread Jorge Scandaliaris
Benjamin Root ben.root@... writes:

snip
 
 Essentially, you make a Path object using the vertices, and then use its 
 contains_point() method.
 Ben Root
 

OK, but given that contains_point works with a *single* point at a time, I have
to call it for all my points which is a bit more cumbersome, or am I missing
something?

Jorge




--
Virtualization  Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Has nxutils been removed from mpl?

2012-03-07 Thread Jorge Scandaliaris
Hi,
I've had an import error with some of my code, specifically with nxutils (I need
it for using points_inside_poly). 

In [1]: import matplotlib.nxutils as nx
---
ImportError   Traceback (most recent call last)
/home/jscandal/ipython-input-1-c56b9729b42e in module()
 1 import matplotlib.nxutils as nx

ImportError: No module named nxutils

I built mpl from trunk and tried also version 1.1 from my distro, but neither
seems to have nxutils. I still find the examples in the docs using it, though,
so I am confused.
Has nxutils been replaced or removed? 

Thanks

Jorge


--
Virtualization  Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Problem building doc in trunk

2012-03-06 Thread Jorge Scandaliaris
Hi, I updated mpl to trunk today and I received the followin error when trying
to build the documentation:

$ python2 make.py html
Running Sphinx v1.1.2

Extension error:
Could not import extension matplotlib.sphinxext.mathmpl (exception:
libpng14.so.14: cannot open shared object file: No such file or directory)
Building HTML failed.

My distribution uses libpng 1.58, so it's no surprise there's no libpng14.
Matplotlib itself detected the libpng version OK and built correctly. Any ideas?

Thanks,

Jorge


--
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Problem building doc in trunk

2012-03-06 Thread Jorge Scandaliaris
Benjamin Root ben.root@... writes:

 
 Strange.  Could you include the entire sphinx output as well as any logs that
the build produced?Ben Root
 

Well, all the output available was what I posted. I don't see any log file in
the build directory. I added the -P option to sphinx-build, the output is below.
I'll keep looking here, maybe there is a problem in my setup

$ sphinx-build -P -b html -d build/doctrees . build/html
Running Sphinx v1.1.2
Exception occurred while building, starting debugger:
Traceback (most recent call last):
  File /usr/lib/python2.7/site-packages/sphinx/cmdline.py, line 188, in main
warningiserror, tags)
  File /usr/lib/python2.7/site-packages/sphinx/application.py, line 114, in
__init__
self.setup_extension(extension)
  File /usr/lib/python2.7/site-packages/sphinx/application.py, line 250, in
setup_extension
err)
ExtensionError: Could not import extension matplotlib.sphinxext.mathmpl
(exception: libpng14.so.14: cannot open shared object file: No such file or
directory)
 /usr/lib/python2.7/site-packages/sphinx/application.py(250)setup_extension()
- err)
(Pdb) q

Jorge


--
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Problem building doc in trunk

2012-03-06 Thread Jorge Scandaliaris
Benjamin Root ben.root@... writes:


 You might need to do a complete rebuild of your mpl trunk.  I would guess 
 that 
 you originally built mpl when you had the older version of libpng.  When you 
 updated the library, that wouldn't trigger a relink of _png.so whenever you 
 rebuilt the trunk.  Wipe out the _png.so file and rebuild.Ben Root

OK. it's fixed now. It was probably all my fault, as I changed the way I
installed matplotlib. Before I was using the python setupegg.py develop
alternative and today I did python setup.py install (blame command line
completion). 
Thanks for your help.

Jorge




--
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] key_press_event weirdness

2011-10-14 Thread Jorge Scandaliaris
Benjamin Root ben.root@... writes:


 
 Which backend and platform are you using?Ben Root
 

I run Arch Linux x86_64 and I am using the GTKAgg backend. I tried both with
IPython and python directly (2.7.2).

jorges


--
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2d-oct
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] key_press_event weirdness

2011-10-14 Thread Jorge Scandaliaris
John Hunter jdh2358@... writes:

 
 I am not seeing this on  Linux x86_64 with backend GTKAgg version
 2.22.0 on python 2.7.  Eg, if I run:
 
  python simple_plot.py -dgtkagg
 
 and then hover over the axes window (w/o clicking on it but the window
 has the focus on hover) and press 'g') the grids is toggled.
 
 JDH

You're right, John, it works here too with the gtkagg backend. I have just
noticed that I had different backend options set in matplotlib.conf and
matplotlibrc. My initial report refers then to the Qt4Agg backend.

BTW, which of matplotlib.conf or matplotlibrc is preferred?

jorges


--
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2d-oct
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] key_press_event weirdness

2011-10-13 Thread Jorge Scandaliaris
Hi,

I am experiencing something a bit strange with 'key_press_event': The event is
not detected unless I click with the mouse on the canvas (The grey area around
the axis). I verified this with my own code as well as with some unmodified
example (
http://matplotlib.sourceforge.net/examples/event_handling/keypress_demo.html?highlight=key_press_event
).
I built mpl from a recent revision (a few days old).

Does anyone else experience this? Is this the expected behavior? I believe it
was enough to have the figure window focused to get key events before, but I
haven't used this feature for some time.

Thanks,

Jorges


--
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2d-oct
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Problem with events when interactive is on

2011-06-10 Thread Jorge Scandaliaris
Hi,

Are events supposed to be used in non-interactive mode? I've been having some
weird issues recently (see
http://thread.gmane.org/gmane.comp.python.matplotlib.general/26233/focus=26267)
which, just by chance, I pinned down to having matplotlib.interactive(True) in
my custom ipython's pylab profile. What's the relationship between both things?
I couldn't find much about interactive mode in the docs.
 
Maybe this does not add useful info to the problem, but I have also noticed a
difference in behavior when running scripts with events handling and interactive
mode on from ipython compared to python. The figure(s) stay displayed when using
ipython, although custom events don't work (predefined events like pan/zoom
still work), while in python the figures are closed once the script finishes.

At least I have a way now to run my scripts from within ipython, even if I don't
understand what's going on.

jorges


--
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Problem with events when interactive is on

2011-06-10 Thread Jorge Scandaliaris
Benjamin Root ben.root@... writes:


 Jorges,
 iPython can do some special things with matplotlib's interactivity when 
 invoked in certain ways (hence why it was called interactive python).  I 
 don't know the particulars of what ipython does, but this does not surprise 
 me.  Does everything work as you expect in interactive mode through regular 
 python?
 Ben Root

Well, I don't know what's the expected behavior. If I set interactive to no,
then my script works OK in python (and also in ipython, btw). If I set it to
yes, though, the figures appear and are closed as soon as the script ends in
python, and they stay open but with the custom events non-functional in ipython.
That might be the expected behavior, and I started to see this behavior because
something changed in ipython (maybe the default was non-interactive before, or
something more complicated in the way ipython deals with matplotlib). I searched
the documentation about details of how interactive works and/or any caveats, but
didn't find much, and hence the question here.
For now I'll turn off interactive, as that seems to make my scripts work as they
did before.
Cheers,

jorges



--
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Problem with events and window resizing

2011-02-07 Thread Jorge Scandaliaris
Jorge Scandaliaris jorgesmbox-ml@... writes:

 snip 
 I couldn't come up with a simple example showing the problem. My attempts so 
 far
 ended in working examples. I did find a change in my code that triggers the
 problem: My code uses a modified version of the lasso_demo example, contains 
 two
 axes, where I draw an image with imshow and a collection of circles with
 scatter. Originally scatter was called with a fixed size for all points, and I
 just changed it so each points gets a different size. 
 
 Just don't ask me why this seemingly innocent change affects (breaks) the 
 event
 handling. I hope somebody can give me some hints. I'll keep checking the code 
 to

Because I couldn't reproduce the problem on simple examples, and also because I
have time constraints related to my work, I decided to go on ignoring this
problem (I can always avoid resizing windows...). This afternoon, I realized
that the problem had not appeared during the whole day, but then realized that
because I was debugging some changes introduced in my code, I had been using
very small images. After switching back to normal sizes, the problem came back. 

So, I modified the lasso_demo, increasing progressively the number polygons
drawn. When I reached 10 polygons, I was able to reproduce the problem. It's
true that this a rather large number, but in my code it happens well below this
number, maybe because I assign a different color and size to each polygon. So my
previous observation that setting different sizes triggered the problem might
not be the real picture. It seems as if I was hitting some sort of limit.

Anyone would have a clue about what could be happening, or how can I try to
debug this?

Thanks,

jorges




--
The modern datacenter depends on network connectivity to access resources
and provide services. The best practices for maximizing a physical server's
connectivity to a physical network are well understood - see how these
rules translate into the virtual world? 
http://p.sf.net/sfu/oracle-sfdevnlfb
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Problem with events and window resizing

2011-02-07 Thread Jorge Scandaliaris
Jorge Scandaliaris jorgesmbox-ml@... writes:

 snip 
 So, I modified the lasso_demo, increasing progressively the number polygons
 drawn. When I reached 10 polygons, I was able to reproduce the problem. 
 It's
 true that this a rather large number, but in my code it happens well below 
 this
 number, maybe because I assign a different color and size to each polygon. So 
 my
 previous observation that setting different sizes triggered the problem might
 not be the real picture. It seems as if I was hitting some sort of limit.
 
 Anyone would have a clue about what could be happening, or how can I try to
 debug this?
 

Well, I am bit desperate. The event problem definitely is related to the number
of polygons, circles, ellipses I draw, as well as to using different colors and
sizes. I don't even know how to start debugging this. 

One step forward, though, is that I checked running the script directly from
python, instead of within ipython, and it is running as it should. This is with
more than 300 thousand ellipses, whereas within ipython it stops working with as
little as 2 thousand ellipses.

I am running both matplotlib and ipython development trees. 

Any expert on how events work out there? And mpl-inpython interaction?

Thanks for any hints/suggestions.

jorges


--
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Problem with events and window resizing

2011-02-07 Thread Jorge Scandaliaris
2011/2/8 Benjamin Root ben.r...@ou.edu



 Hmm, interesting observation.  There is very little in mpl that limits your
 ability to produce elements for plotting (which is probably why you were
 getting shrugs from the mailing list...).  However, ipython has various
 tricks for caching mpl elements, and can sometimes be a bit excessive in
 memory usage.  This could lead to some issues.

 Now that you have identified ipython as the culprit, I would suggest taking
 this to the ipython list and seeing if they can better identify the problem
 for you.

 Ben Root


Thanks, I was thinking of doing that myself.

jorges
--
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Problem with events and window resizing

2011-02-05 Thread Jorge Scandaliaris
Jorge Scandaliaris jorgesmbox-ml@... writes:

 snip 
 
 The symptoms are that
 the interaction (keys and mouse clicks) works OK as long as I don't resize the
 window. Once I do this, the interaction is gone. What happens when the window
 is
 resized, that could be related to what I experience.
 
 OK, lets see if I can come up with a simple code reproducing this...
 

I couldn't come up with a simple example showing the problem. My attempts so far
ended in working examples. I did find a change in my code that triggers the
problem: My code uses a modified version of the lasso_demo example, contains two
axes, where I draw an image with imshow and a collection of circles with
scatter. Originally scatter was called with a fixed size for all points, and I
just changed it so each points gets a different size. 

Just don't ask me why this seemingly innocent change affects (breaks) the event
handling. I hope somebody can give me some hints. I'll keep checking the code to
see if I find anything suspicious.

jorges




--
The modern datacenter depends on network connectivity to access resources
and provide services. The best practices for maximizing a physical server's
connectivity to a physical network are well understood - see how these
rules translate into the virtual world? 
http://p.sf.net/sfu/oracle-sfdevnlfb
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Problem with events and window resizing

2011-02-04 Thread Jorge Scandaliaris
Hi,
I have some code that's been working for a long time, but it's behaving strange
with current (svn) matplotlib. It's too large to post here, so I will try to
come up with a minimal version reproducing the problem. Meanwhile, I wanted to
ask if anyone would have a clue of what could be going on. The symptoms are that
the interaction (keys and mouse clicks) works OK as long as I don't resize the
window. Once I do this, the interaction is gone. What happens when the window is
resized, that could be related to what I experience.

OK, lets see if I can come up with a simple code reproducing this...

jorges


--
The modern datacenter depends on network connectivity to access resources
and provide services. The best practices for maximizing a physical server's
connectivity to a physical network are well understood - see how these
rules translate into the virtual world? 
http://p.sf.net/sfu/oracle-sfdevnlfb
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Problem with show()

2010-10-06 Thread Jorge Scandaliaris
Eric Firing efir...@... writes:

 For this to work, you need to be in matplotlib's interactive mode, 
 either by running ipython with the -pylab option, or by calling 
 plt.ion() before your call to show().  In either of these cases, your 
 example code works for me with ipython from git, mpl from svn, and using 
 drag/drop to enter the code in ipython.  I am also on ubuntu 10.10, 
 64-bit, with gtkagg backend.
 
 Eric
 

I was running my example with the -pylab option set in ipython, and adding a
call to plt.ion() doesn't change things. I also run gtkagg backend. I guess I
have a problem with my installation of matplotlib, unless this is something that
changed after mpl-1.0. I will try mpl-svn next and see.

Regards,

Jorge


--
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2  L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Problem with show()

2010-10-05 Thread Jorge Scandaliaris
Hi,
Today I tried to run some code in my new notebook, but I only got blank figures
and high CPU usage as a result. This code did run on my previous laptop. I can
reproduce this behavior with the following code at the bottom of this message.
The backtrace (also at the bottom this message) points to show() as the cause of
the problem. The reason I have show() at the top is because in my code the call
to plot() is done within a loop (I reuse the same figure for multiple plots). I
still have to check all software versions in detail from the older laptop, but I
wanted to ask here in case this was a known problem. I have ipython from git,
and matplotlib 1.0, this is a 64 bit OS (Ubuntu 10.10). Matplotlib was installed
from source. In the other laptop (Ubuntu 10.4, 32 bits) there's also ipython
from git (although an older revision) and matplotlib 1.0 compiled from source.

Regards,

Jorge


example code showing the problem
8-
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt

fig, ax = plt.subplots(1,1)
plt.show()
data = np.random.randn(10)
ax.plot(data)
fig.canvas.draw()
8-

backtrace after hitting CTRL-C
8-
In [2]: run doct/intrinsic-images/test_show.py
^C---
KeyboardInterrupt Traceback (most recent call last)
/home/jscandal/sw/python/doct/intrinsic-images/test_show.py in module()
  5 
  6 fig, ax = plt.subplots(1,1)
 7 plt.show()
  8 data = np.random.randn(10)
  9 ax.plot(data)

/home/jscandal/lib/python2.6/site-packages/matplotlib/backends/backend_gtk.pyc
in show(mainloop)
 76 if mainloop and gtk.main_level() == 0 and \
 77 len(Gcf.get_all_fig_managers())0:
--- 78 gtk.main()
 79 
 80 def new_figure_manager(num, *args, **kwargs):

KeyboardInterrupt: 




--
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2  L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Confused/frustrated w/ waitforbuttonpress

2010-08-07 Thread Jorge Scandaliaris
Eric Firing efir...@... writes:


 Running mpl from svn, with gtkagg backend, on ubuntu, but with ipython 
 0.11alpha1, I can't reproduce the problem; your example works for me.  I 
 suspect the difference is that ipython 0.11 uses a non-threaded 
 interactive mode, while 0.10 uses the threaded mode.  Is updating your 
 ipython an option for you?
 
 Eric
 

Yes, it is. I'll give it a try. Thanks for the info.

Jorge


--
This SF.net email is sponsored by 

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Confused/frustrated w/ waitforbuttonpress

2010-08-07 Thread Jorge Scandaliaris
Eric Firing efir...@... writes:
 Running mpl from svn, with gtkagg backend, on ubuntu, but with ipython 
 0.11alpha1, I can't reproduce the problem; your example works for me.  I 
 suspect the difference is that ipython 0.11 uses a non-threaded 
 interactive mode, while 0.10 uses the threaded mode.  Is updating your 
 ipython an option for you?
 
 Eric
 

Well, I just installed ipython 0.11.alpha1.git and my example doesn't work at
all (first plot is displayed, but neither mouse nor key presses have any
effect). Could it be that I use mpl.1.0 instead of svn? How do you start
ipython? I usually do ipython -gthread -pylab, but maybe that is also
contributing to the problem.

Regards,

Jorge


--
This SF.net email is sponsored by 

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Scatter legend with colored marker

2010-08-06 Thread Jorge Scandaliaris
Jae-Joon Lee lee.j.j...@... writes:

snip
 In recent versions, there is a separate parameter : scatterpoints. So
 check your document.
 
  ax.legend(sc, labels, scatterpoints=1)
 
 Regards,
 
 -JJ

Great! It works fine with 1.0.0

Jorge


--
This SF.net email is sponsored by 

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Confused/frustrated w/ waitforbuttonpress

2010-08-06 Thread Jorge Scandaliaris
Hi,
Looking for a way to analyze a set of images I found waitforbuttonpress, which
basically does what I need: allows me to display a few plots/scatter/etc for as
long as I need; then when pressing a key move to the next image and redo all
plots/scatter/etc. 
Now my problem is that waitforbuttonpress (or the (mis)use I gave it) forces me
to close the ipython session frequently and start over again. This is at least
inconvenient, and a few times forced me to recalculate things that took some
time (and that I had forgot to save). 
I know this might be backend-related. I use GTKAgg, on ubuntu 10.04, mpl-1.0.0
(locally built). Below you'll find a script I created where I see this behavior,
the ipython console's output, and the steps I followed.

Steps followed and description:
1- Run script, click mouse a few times (plot is closed and redrawn), finally
press a key. The plot is closed, and the console returns to be active. This
corresponds to In [1] in the ipython console's output
2- Trying to run anything at the ipython console results in a looong delay and a
message like in In [2] at the console. The console works fine after this,
though, at least with non matplotlib-related stuff
3- Running the script again results in the output shown in In [3]. The script
seems to runs fine, i.e. clicks cause the redrawing of the plot, though pressing
any key (which should break the loop and end the script) will end the script but
won't close the plot windows. The console works mostly ok, the only way to close
the plot window and ipython is by killing the ipython process.
4- In some other cases, I ended up with an unresponsive console that required
killing the ipython process as well.
This test case is not comprehensive of the things I've experienced, but it might
show a possible cause of this behavior.

Regards,

Jorge


Ipython console's output:

In [1]: run doct/intrinsic-images/test_waitforbuttonpress.py
/home/jscandal/lib/python2.6/site-packages/matplotlib/backend_bases.py:2051:
DeprecationWarning: Using default event loop until function specific to this GUI
is implemented
  warnings.warn(str,DeprecationWarning)

In [2]: run doct/intrinsic-images/test_waitforbuttonpress.py
Warning: Timeout for mainloop thread exceeded
switching to nonthreaded mode (until mainloop wakes up again)

In [3]: run doct/intrinsic-images/test_waitforbuttonpress.py
---
ValueErrorTraceback (most recent call last)

/usr/lib/pymodules/python2.6/IPython/Shell.pyc in on_timer(self)
847 
848 update_tk(self.tk)
-- 849 self.IP.runcode()
850 time.sleep(0.01)
851 return True

/usr/lib/pymodules/python2.6/IPython/Shell.pyc in runcode(self)
455 # code modifies it, we restore our own handling.

456 try:
-- 457 signal(SIGINT,sigint_handler)
458 except SystemError:
459 # This happens under Windows, which seems to have all sorts


ValueError: signal only works in main thread
-
 
script used in the test:

import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt

data = np.random.rand(10,2)

while True:
fig, ax = plt.subplots(1,1)
ax.scatter(data.T[0], data.T[1])
plt.show()
if fig.waitforbuttonpress(timeout=-1):
plt.close('all')
break
plt.close('all')


--
This SF.net email is sponsored by 

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Scatter legend with colored marker

2010-08-05 Thread Jorge Scandaliaris
Benjamin Root ben.r...@... writes:
 
snip
 Probably not directly, but I hadn't thought about that before.  For a set of 
 scatter points that are colored by values, what should the legend show?  In 
 other words, what does it *mean* for there to be a legend for points that are 
 colored in a potentially non-uniform manner?So, maybe this is desired 
 behavior 
 (but possibly by accident)?
 Thanks for your help,
 Ben Root

I thought for a moment that legend was using the color of the first point in the
set, but a quick test reveals that no matter what colormap you specify, the
marker color inside the legend is blue. BTW, I think I've found another thing
related to legend() and scatter plots: the 'numpoints' keyword argument to
legend is not respected, as showed in the example pasted below,

Jorge

---
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt

data0 = np.random.rand(10,2)
data1 = np.random.rand(10,2)
data2 = np.random.rand(10,2)
data = [data0, data1, data2]

fig, ax = plt.subplots(1,1)
norm = mpl.colors.Normalize(0,len(data))
cmap = mpl.cm.afmhot

sc = []
labels = []
for i,d in enumerate(data):
sc.append(ax.scatter(d.T[0], d.T[1], c=np.ones(d.shape[0])*i,
norm=norm, cmap=cmap))
labels.append('data set ' + str(i))
ax.legend(sc, labels, numpoints=1)
plt.show()
---



--
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Scatter legend with colored marker

2010-08-04 Thread Jorge Scandaliaris
Jorge Scandaliaris jorgesmbox...@... writes:
 
 Hi,
 I am adding several scatter plots to the same axis, each having a specific
 color. When I call legend on the axis it correctly picks all scatter plots 
 with
 their symbols and labels, but it doesn't pick up the color. The example below
 demonstrates this. What I would like to do is to have in the legend the marker
 its color matching that of the set it represents. How would I do this? 

Answering my own question, I found a way to achieve what I wanted by using a
proxy artist as suggested in this thread:
http://thread.gmane.org/gmane.comp.python.matplotlib.general/20995/focus=20999

Maybe there's a better approach. I certainly would love legend to pick up on the
color used in the scatter plot by its own.

Jorge


--
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Scatter legend with colored marker

2010-08-04 Thread Jorge Scandaliaris
Benjamin Root ben.r...@... writes:

snip
 Hmm, this definitely looks like a bug.  If I explicitly state what color I 
 want
 using the color keyword instead of using 'c' and 'norm', then everything
 works properly.

I can't tell if this is a bug or not, but the trick of using a color directly is
an even simpler workaround than the one I used. Thanks.

Jorge


--
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Scatter legend with colored marker

2010-08-04 Thread Jorge Scandaliaris
Benjamin Root ben.r...@... writes:

snip
 Hmm, this definitely looks like a bug. 

Should I fill a bug report about this?

Jorge


--
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Scatter legend with colored marker

2010-08-04 Thread Jorge Scandaliaris
Benjamin Root ben.r...@... writes:

snip
 
 Yes, please do, and then mention which bug report you filed to this thread.
Ben Root

Done. Bug number is 3039678 

Could this behavior be due to the fact that scatter() accepts sequences for
setting the color of each point individually? Maybe I am way off, but who 
knows...

Jorge


--
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] LineCollection: multiple ways of setting colors?

2010-06-08 Thread Jorge Scandaliaris
Hi,
I am working with collection of lines, and when trying to set the color of each
individual lines I found that you can either use a 'color' or colors' (note the
's') argument to LineCollection() to accomplish the same, but that there's only
a set_color() method you can call. Is this intended? 
Also, I found (and already used elsewhere) the set_array() method, which
complains when passed rgba values but works when passed a vector. I haven't
found much on its purpose, except for what appears under
matplotlib.cm.ScalarMappable() and the various examples using it. I guessed I am
a little confused.

Jorges


--
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Ways of updating legends

2010-02-11 Thread Jorge Scandaliaris
Hi,
I am re-using a scatter plot in the same figure for interactively displaying
results without ending up with 30 windows open. The legend is relevant, and so
it must be also updated. So far the only way I found was to use the set_label()
method and then using plt.legend(). Is this the only way to get a legend updated
from a label? I am curious, since generally there is the pyplot way and a more
OO way of achieving things, but I could't find it this time.

The snippet below shows what I am using right now:

import numpy as np
import scipy as sp
import matplotlib as mpl
import matplotlib.pyplot as plt

data = np.random.randn(3,10) 
fig = plt.figure()
ax = fig.add_subplot(111)
s, = ax.plot([])
ax.axis([0,10,-1,1])
ax.legend([s],[''], loc=0)
for i in range(data.shape[0]):
s.set_data([np.arange(data.shape[1]),data[i]])
s.set_label(str(i))
plt.legend()
plt.draw()
plt.ginput(timeout=0)



--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Ways of updating legends

2010-02-11 Thread Jorge Scandaliaris
El 11/02/10 18:28, Jae-Joon Lee escribió:
 You're already using ax.legend, what kind of OO way do you want?
 
 Instead of calling plt.legend, you may do
ax.legend([s],[str(i)])
 

Thanks Jae-Joon. You're right. I tried this before, but I must have done
something wrong then, because when I tried the result were new legends
stacked upon the old ones, which didn't look nice when the new legend
was shorter than previous ones.


 Or, if you know what you're doing, you can do
 
 leg = ax.legend([s],[''], loc=0)
 
 and in the for loop,
 
leg.texts[0].set_text(str(i))
 

This is even nicer. I tried something similar but somehow overlooked the
texts[0] part, so it didn't work. I'll have to go back to the docs...



Regards,

Jorge

--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Extending patches.Rectangle class

2009-12-03 Thread Jorge Scandaliaris
Jae-Joon Lee lee.j.j...@... writes:
...
 
 It depends on your mileage.
 
 However, a patch in matplotlib usually means a closed path. If you add
 additional lines, you need to be careful not to mess the filling of
 the rectangle.
 
 I guess it would better to simply use separate artists for additional
 lines you want. You may create a container artist for patches and
 lines if you want.
 
 Regards,
 
 -JJ

Thanks, that's sounds like a better way indeed. I'll work in this direction.

Jorge



--
Join us December 9, 2009 for the Red Hat Virtual Experience,
a free event focused on virtualization and cloud computing. 
Attend in-depth sessions from your desk. Your couch. Anywhere.
http://p.sf.net/sfu/redhat-sfdev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Draggable and resizeable rectangle example

2009-12-01 Thread Jorge Scandaliaris
Hi,
I just had to label a sequence of images with the position and scale of a moving
object. To do this I took the nice example from
http://matplotlib.sourceforge.net/users/event_handling.html (the one using
blitting) and extended to be resizeable. The extension is trivial, but it might
be useful to someone. The code is inlined at the end of this message.

Jorge

# draggable rectangle with the animation blit techniques; see
# http://www.scipy.org/Cookbook/Matplotlib/Animations
import numpy as np
import matplotlib.pyplot as plt

class DraggableResizeableRectangle:

Draggable and resizeable rectangle with the animation blit techniques.
Based on example code at
http://matplotlib.sourceforge.net/users/event_handling.html
If *allow_resize* is *True* the recatngle can be resized by dragging its
lines. *border_tol* specifies how close the pointer has to be to a line for
the drag to be considered a resize operation. Dragging is still possible by
clicking the interior of the rectangle. *fixed_aspect_ratio* determines if
the recatngle keeps its aspect ratio during resize operations.

lock = None  # only one can be animated at a time
def __init__(self, rect, border_tol=.15, allow_resize=True,
 fixed_aspect_ratio=True):
self.rect = rect
self.border_tol = border_tol
self.allow_resize = allow_resize
self.fixed_aspect_ratio = fixed_aspect_ratio
self.press = None
self.background = None

def connect(self):
'connect to all the events we need'
self.cidpress = self.rect.figure.canvas.mpl_connect(
'button_press_event', self.on_press)
self.cidrelease = self.rect.figure.canvas.mpl_connect(
'button_release_event', self.on_release)
self.cidmotion = self.rect.figure.canvas.mpl_connect(
'motion_notify_event', self.on_motion)

def on_press(self, event):
'on button press we will see if the mouse is over us and store some 
data'
if event.inaxes != self.rect.axes: return
if DraggableRectangle.lock is not None: return
contains, attrd = self.rect.contains(event)
if not contains: return
#print 'event contains', self.rect.xy
x0, y0 = self.rect.xy
w0, h0 = self.rect.get_width(), self.rect.get_height()
aspect_ratio = np.true_divide(w0, h0)
self.press = x0, y0, w0, h0, aspect_ratio, event.xdata, event.ydata
DraggableRectangle.lock = self

# draw everything but the selected rectangle and store the pixel buffer
canvas = self.rect.figure.canvas
axes = self.rect.axes
self.rect.set_animated(True)
canvas.draw()
self.background = canvas.copy_from_bbox(self.rect.axes.bbox)

# now redraw just the rectangle
axes.draw_artist(self.rect)

# and blit just the redrawn area
canvas.blit(axes.bbox)

def on_motion(self, event):
'on motion we will move the rect if the mouse is over us'
if DraggableRectangle.lock is not self:
return
if event.inaxes != self.rect.axes: return
x0, y0, w0, h0, aspect_ratio, xpress, ypress = self.press
self.dx = event.xdata - xpress
self.dy = event.ydata - ypress
#self.rect.set_x(x0+dx)
#self.rect.set_y(y0+dy)

self.update_rect()

canvas = self.rect.figure.canvas
axes = self.rect.axes
# restore the background region
canvas.restore_region(self.background)

# redraw just the current rectangle
axes.draw_artist(self.rect)

# blit just the redrawn area
canvas.blit(axes.bbox)

def on_release(self, event):
'on release we reset the press data'
if DraggableRectangle.lock is not self:
return

self.press = None
DraggableRectangle.lock = None

# turn off the rect animation property and reset the background
self.rect.set_animated(False)
self.background = None

# redraw the full figure
self.rect.figure.canvas.draw()

def disconnect(self):
'disconnect all the stored connection ids'
self.rect.figure.canvas.mpl_disconnect(self.cidpress)
self.rect.figure.canvas.mpl_disconnect(self.cidrelease)
self.rect.figure.canvas.mpl_disconnect(self.cidmotion)

def update_rect(self):
x0, y0, w0, h0, aspect_ratio, xpress, ypress = self.press
dx, dy = self.dx, self.dy
bt = self.border_tol
fixed_ar = self.fixed_aspect_ratio
if (not self.allow_resize or
(abs(x0+np.true_divide(w0,2)-xpress)np.true_divide(w0,2)-bt*w0 and
 abs(y0+np.true_divide(h0,2)-ypress)np.true_divide(h0,2)-bt*h0)):
self.rect.set_x(x0+dx)
self.rect.set_y(y0+dy)
elif abs(x0-xpress)bt*w0:
self.rect.set_x(x0+dx)
self.rect.set_width(w0-dx)
if fixed_ar:
 

[Matplotlib-users] Extending patches.Rectangle class

2009-12-01 Thread Jorge Scandaliaris
Hi,
How difficult would be to extend the Rectangle class so besides its permimeter
it draws lines showing halfs or thirds of the width and height? I use rectangle
to mark the locations of moving objects in sequences of images, and such lines
would make the job easier.

Thanks,

Jorge


--
Join us December 9, 2009 for the Red Hat Virtual Experience,
a free event focused on virtualization and cloud computing. 
Attend in-depth sessions from your desk. Your couch. Anywhere.
http://p.sf.net/sfu/redhat-sfdev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Bug in matplotlib.patches' contains() method?

2009-11-30 Thread Jorge Scandaliaris
Michael Droettboom md...@... writes:

 
 It shouldn't always return True -- it should return a tuple of type 
 (bool, dict).  The first element is whether it's inside, and the second 
 is a dictionary of indices of subobjects (used only for Collections).  
 Unfortunately, this tuple always evaluates to True.  Have you tried 
 changing your contains test from .contains() to .contains()[0]?
 
 If that's not what's happening for you, can you send a self-contained 
 example that illustrates this bug?
 
 (I noticed the looking_glass.py example has this bug -- I'll fix that.)
 
 Mike

You're right. I keep making these dumb mistakes... This time it was made worst
cause the looking_glass.py example did the same. 

Jorge


--
Join us December 9, 2009 for the Red Hat Virtual Experience,
a free event focused on virtualization and cloud computing. 
Attend in-depth sessions from your desk. Your couch. Anywhere.
http://p.sf.net/sfu/redhat-sfdev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Customize/disable keyboard shortcuts

2009-11-29 Thread Jorge Scandaliaris
Hi,
I have a strong preference to working with the keyboard instead of the mouse.
Today I was working on a script to label a sequence of images (mark position and
scale of a moving object). The default keyboard shortcuts are getting in my way,
many keys are already used and moreover they are spread all over the keyboard.
Looking at the doc, I could't find an easy way to customize or completely
disable them. If someone can suggest a (not too coonvoluted) solution, I'd love
to hear it.

Cheers,

Jorge


--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Bug in matplotlib.patches' contains() method?

2009-11-28 Thread Jorge Scandaliaris
Hi,
I was trying to find out when a button_press_event happened inside a patch
(tried Circle and Rectangle) using the contains(mouseevent) method, but it
always seem to return True. I got the inspiration from the looking_glass.py
example, which also doesn't work as (Ithink) it should. I know Ican do this the
hard way, i.e. checking with event.xdata event.ydata, but I was really happy
there was already a pre-defined method for doing so.

Cheers,

Jorge


--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Error in doc?

2009-09-09 Thread Jorge Scandaliaris
Hi,
I think I found a bug, but I am not sure if it's in the doc or in a method name.
In the doc, there is reference to a method *suptitle* in class
mpl.figure.Figure. The name sounds strange, but the method exists and works. The
example given, though, makes reference to *subtitle*, so either the example or
the method name are wrong. Here's the link to the doc:
http://matplotlib.sourceforge.net/api/figure_api.html?highlight=legend#matplotlib.figure.Figure.suptitle

jorge


--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Questions about GUIs

2009-07-25 Thread Jorge Scandaliaris
Hi,
I am trying to use matplotlib to visually explore certain different
representation of images. I have the core functionality done. This allows to
explore one image that appears on two subplots w/ the possibility to highlight
regions on either subplot and see the corresponding one on the other. 
What I have left to do is to provide some mean to select the image one wants to
explore. I tried to follow some advice given on this list, but it seems gui
dialogs (file selection in this case) don't get along well with the thread
tricks done by ipython to maintain interactivity while using matplotlib (ipython
started w/ -gthread or -pylab option). If I start ipython without options, the
dialogs do respond, but then I loose the ipython shell. Am I trying to do
something out of normal with matplotlib? I would appreciate any advice or
pointers that would allow me overcome these limitations.


Jorge


--
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Possible problem with mpl.axes .Axes.add_collection()

2009-07-24 Thread Jorge Scandaliaris
Jorge Scandaliaris jorgesmbox...@... writes:

 
  jorgesmbox...@... writes:
 
  
  Hi,
  I have a strange problem. It seems to me it is related to 
  mpl.axes.Axes.add_collection(), but I am too lost to be sure. 
 
 Well, I haven't solved this problem yet, but it seems that the 
 add_collection()
 method is not the one at fault. It looks like the lasso widget I am using to
 selct the regions is returning for the fourth region the same vertices than 
 for
 the third one. 

Well, definitely I was wrong at my initial guess. It turns out the problem was a
race condition in the LassoManager class handling the Lasso widget. Putting a
few print statements here and there revealed the problem: I had two callback
functions competing against each other, one called by the lasso widget and the
other connected to mouse release event. One of them was setting a variable used
by the other. My guess is I (mis)used an old version of the lasso_demo, because
when I re visited the example section yesterday, I realized the lasso_demo had
no callback connected to the mouse release event.
I write this as a reference, hoping it can help someboby in the future.

Jorge



--
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Open file dialog?

2009-06-05 Thread Jorge Scandaliaris
Alan G Isaac alan.is...@... writes:
snip
 That's all, as long as you don't mind destroying
 the Window manually.  (Otherwise, you need just
 a couple more lines.)
 

Thanks, I'll give this a try.


Jorge



--
OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
looking to deploy the next generation of Solaris that includes the latest 
innovations from Sun and the OpenSource community. Download a copy and 
enjoy capabilities such as Networking, Storage and Virtualization. 
Go to: http://p.sf.net/sfu/opensolaris-get
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users