[Matplotlib-users] Interactive selecting a quadrilateral from a axes

2012-07-11 Thread Wolfgang Draxinger
Hi,

I have a plot of an image of which I'd like to interactively select a
quadrilateral. This is for a homography operation (perspective
correction). It suffices if the quadrilateral can be dragged by only
its vertices (display the vertices as rects or circled to click within).

In principle I want to implement a tool similar to the
Perspective tool of The GIMP in corrective mode. The whole image
processing and geometric transformation is already implemented, but now
I need a user interface. Since I'm already making heavy use of
Matplotlib I'd like to stay within this.

After the user applied the homography the next step is placing the
calibration markers, which would be basically one axvline and two
axhlines to be dragged to reference points on the previously
perspective corrected image.

How do I implement such interaction elements?


Wolfgang

--
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] Interactive selecting a quadrilateral from a axes

2012-07-11 Thread Tony Yu
On Wed, Jul 11, 2012 at 8:35 AM, Wolfgang Draxinger 
wdraxinger.maill...@draxit.de wrote:

 Hi,

 I have a plot of an image of which I'd like to interactively select a
 quadrilateral. This is for a homography operation (perspective
 correction). It suffices if the quadrilateral can be dragged by only
 its vertices (display the vertices as rects or circled to click within).

 In principle I want to implement a tool similar to the
 Perspective tool of The GIMP in corrective mode. The whole image
 processing and geometric transformation is already implemented, but now
 I need a user interface. Since I'm already making heavy use of
 Matplotlib I'd like to stay within this.

 After the user applied the homography the next step is placing the
 calibration markers, which would be basically one axvline and two
 axhlines to be dragged to reference points on the previously
 perspective corrected image.

 How do I implement such interaction elements?


 Wolfgang


Hi Wolfgang,

You can find a decent start to this in the event handling examples. The
poly editor demo is particularly useful:


http://matplotlib.sourceforge.net/examples/event_handling/poly_editor.html

Awhile back, I wrote a tool for my own work. It probably needs a little
cleanup, but it works. I've posted it as a gist if you want to try it out:

https://gist.github.com/3090704

At some point, I had problems with it on certain backends, so you may need
to uncomment the 'tkagg' line. In any case, it seems to work fine with my
current backend (qt4agg).

Cheers,
-Tony
--
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


[Matplotlib-users] Saving animation with coloured background

2012-07-11 Thread Pål Gunnar Ellingsen
Hi

I'm trying to save a animation, which I've generated using
animation.FuncAnimation.
The animation has it's background set by plt.rcParams['figure.facecolor'] =
'black'
Which works with plt.show(), though not with animation save.
I know that plt.save needs the argument facecolor to save a figure with a
given background, but the animations save does not like such an argument.
What am I doing wrong?


Kind regards

Pål
--
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] ANN: mpltools 0.1 release

2012-07-11 Thread Damon McDougall
On Tue, Jul 10, 2012 at 05:36:50PM -0400, Tony Yu wrote:
 On Tue, Jul 10, 2012 at 1:52 PM, John Hunter jdh2...@gmail.com wrote:
 
 
  On Tue, Jul 10, 2012 at 12:49 PM, Damon McDougall 
  damon.mcdoug...@gmail.com wrote:
 
 
  Would there be any interest in porting some of that functionality into
  the main mpl codebase? Like Ben said, that error function is nifty... :)
 
 
 
  I also think the styles would be widely appreciated, and we might get more
  styles contributors if it was part of the mainline.  We'd ideally like to
  be able to support remote styles, eg via gist.
 
  Nice stuff, Tony.
 
 
 Damon and John: Thanks for your interest. I would be happy to help port
 anything that can find a home in Matplotlib. I'm low on bandwidth, so if
 I'm too slow with any of it, feel free to grab the code and submit your own
 PR for the port (just let me know so we don't duplicate our efforts).

Well, as Ben said, that error fill plot is neato! It doesn't look too
complicated, either. I'd be more than happy to port it over later today
when I get bored of typing up my thesis. It'll probably only take me
about 30 minutes.

If nobody is opposed to this idea, I'll go ahead and submit a PR this
evening (British Summer (hah!) Time).

-- 
Damon McDougall
http://damon-is-a-geek.com
B2.39
Mathematics Institute
University of Warwick
Coventry
West Midlands
CV4 7AL
United Kingdom

--
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] ANN: mpltools 0.1 release

2012-07-11 Thread John Hunter
On Wed, Jul 11, 2012 at 10:09 AM, Damon McDougall damon.mcdoug...@gmail.com
 wrote:

 Well, as Ben said, that error fill plot is neato! It doesn't look too
 complicated, either. I'd be more than happy to port it over later today
 when I get bored of typing up my thesis. It'll probably only take me
 about 30 minutes.

 If nobody is opposed to this idea, I'll go ahead and submit a PR this
 evening (British Summer (hah!) Time).



While it is a nice graph, I am not sure that the use case is common enough
to justify a new plotting method.  One can get the same result with:


  In [68]: x = np.linspace(0, 2 * np.pi)

  In [69]: y_sin = np.sin(x)

  In [70]: err = np.concatenate([y_sin + 0.2, y_sin[::-1] - 0.2])

  In [71]: plot(x, y_sin)
  Out[71]: [matplotlib.lines.Line2D object at 0x96959ec]

  In [72]: fill_between(np.concatenate([x, x[::-1]]), err, facecolor='red',
alpha=0.5)
  Out[72]: matplotlib.collections.PolyCollection object at 0x962758c

Admittedly the [::-1] thing is a bit counter-intuitive, but rather than
adding a new plotting method, perhaps we would be better off with a helper
method to create the xs and ys for fill_between

  xs, ys = mlab.pad_line(x, y, 0.2)
  fill_between(xs, ys)

JDH
--
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] ANN: mpltools 0.1 release

2012-07-11 Thread Benjamin Root
On Wed, Jul 11, 2012 at 11:23 AM, John Hunter jdh2...@gmail.com wrote:



 On Wed, Jul 11, 2012 at 10:09 AM, Damon McDougall 
 damon.mcdoug...@gmail.com wrote:

 Well, as Ben said, that error fill plot is neato! It doesn't look too
 complicated, either. I'd be more than happy to port it over later today
 when I get bored of typing up my thesis. It'll probably only take me
 about 30 minutes.

 If nobody is opposed to this idea, I'll go ahead and submit a PR this
 evening (British Summer (hah!) Time).



 While it is a nice graph, I am not sure that the use case is common enough
 to justify a new plotting method.  One can get the same result with:


   In [68]: x = np.linspace(0, 2 * np.pi)

   In [69]: y_sin = np.sin(x)

   In [70]: err = np.concatenate([y_sin + 0.2, y_sin[::-1] - 0.2])

   In [71]: plot(x, y_sin)
   Out[71]: [matplotlib.lines.Line2D object at 0x96959ec]

   In [72]: fill_between(np.concatenate([x, x[::-1]]), err,
 facecolor='red', alpha=0.5)
   Out[72]: matplotlib.collections.PolyCollection object at 0x962758c

 Admittedly the [::-1] thing is a bit counter-intuitive, but rather than
 adding a new plotting method, perhaps we would be better off with a helper
 method to create the xs and ys for fill_between

   xs, ys = mlab.pad_line(x, y, 0.2)
   fill_between(xs, ys)

 JDH


At the very least, it should be added to the gallery.  Also, one thing that
might (or might not) get in the way of getting merged into mainline mpl is
how well it interacts with legends.  What does it produce in the legend?

Ben Root
--
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] Saving animation with coloured background

2012-07-11 Thread Benjamin Root
On Wed, Jul 11, 2012 at 10:41 AM, Pål Gunnar Ellingsen paa...@gmail.comwrote:

 Hi

 I'm trying to save a animation, which I've generated using
 animation.FuncAnimation.
 The animation has it's background set by plt.rcParams['figure.facecolor']
 = 'black'
 Which works with plt.show(), though not with animation save.
 I know that plt.save needs the argument facecolor to save a figure with a
 given background, but the animations save does not like such an argument.
 What am I doing wrong?


 Kind regards

 Pål


You aren't doing anything wrong.  It is most likely an oversight on our
part to not consider that use-case.  Could you file a bug report about this?

Cheers!
Ben Root
--
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


[Matplotlib-users] Two panels (wxPython) containing separate figures

2012-07-11 Thread Joshua Koehler
Hi all,

I am currently trying to have two panels each with their own figure instance so 
they can have separate plots. 

I can successfully update a plot if there is only one panel. As soon as I add a 
second panel, I get the following error when I try to update (replot) a plot 
(Showing last message only):

File 
/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/axes.py,
 line 1374, in _sci
Argument must be an image, collection, or ContourSet in this Axes)
ValueError: Argument must be an image, collection, or ContourSet in this Axes

I looked online first and one site suggested it was because I was using 
matplotlib.Figure instead of pylab.Figure. I switched and the problem still 
occurs. I was curious to see if this problem had to do with how I set up my 
program, not with matplotlib, so I wrote a little test program. The exact same 
problem occurs. I have attached the test program. To see that it does work with 
just one panel comment out lines 39, 41, and 49. When put back in, I get the 
above error message.

Any suggestions as to how to fix this?

Thanks!

Josh

import wx
import networkx as nx
import matplotlib.pylab as plt
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas

def my_plot(figure):
figure.clear()
G = nx.star_graph(15)
axes = figure.add_subplot(1,1,1)
nx.draw_networkx(G, ax=axes)

class PanelOne(wx.Panel):
def __init__(self, my_parent, my_id=wx.ID_ANY):
wx.Panel.__init__(self, parent=my_parent, id=my_id)
self.figure = plt.figure()
self.figure.add_subplot(1,1,1)
self.canvas = FigureCanvas(self, wx.ID_ANY, self.figure)
def update_display(self):
my_plot(self.figure)
def close(self):
plt.close()

class PanelTwo(wx.Panel):
def __init__(self, my_parent, my_id=wx.ID_ANY):
wx.Panel.__init__(self, parent=my_parent, id=my_id)
self.figure = plt.figure()
self.figure.add_subplot(1,1,1)
self.canvas = FigureCanvas(self, wx.ID_ANY, self.figure)
def update_display(self):
my_plot(self.figure)
def close(self):
plt.close()

class MyFrame(wx.Frame):
def __init__(self, parent):
wx.Frame.__init__(self,parent=parent)
self.h_sizer = wx.BoxSizer(wx.HORIZONTAL)
self.panel1 = PanelOne(self)
self.panel2 = PanelTwo(self)
self.h_sizer.Add(self.panel1)
self.h_sizer.Add(self.panel2)
self.panel1.update_display()
self.SetSizer(self.h_sizer)
self.Fit()
self.Bind(wx.EVT_CLOSE, self.OnExit)
  
def OnExit(self, event):
self.panel1.close()
self.panel2.close()
self.Destroy()
 
if __name__ == __main__:
app = wx.App(False)
frame = MyFrame(None)
frame.Show(True)
app.MainLoop()
  

 

--
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] Two panels (wxPython) containing separate figures

2012-07-11 Thread Daniel Hyams
To get rid of the networkx dependency, I just replaced my_plot() with this:

def my_plot(figure):
figure.clear()
axes = figure.add_subplot(1,1,1)
axes.plot([0,1,2],[2,3,4])

and also added self.panel2.update_display() in the constructor for
MyFrame, and everything worked fine.  Could it be networkx caching a
reference to a figure or axes that is really the problem?  Can you post the
full stack trace instead of just the last line?



On Wed, Jul 11, 2012 at 12:45 PM, Joshua Koehler jjkoehl...@gmail.comwrote:

 Hi all,

 I am currently trying to have two panels each with their own figure
 instance so they can have separate plots.

 I can successfully update a plot if there is only one panel. As soon as I
 add a second panel, I get the following error when I try to update (replot)
 a plot (Showing last message only):

 File
 /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/axes.py,
 line 1374, in _sci
 Argument must be an image, collection, or ContourSet in this Axes)
 ValueError: Argument must be an image, collection, or ContourSet in this
 Axes

 I looked online first and one site suggested it was because I was using
 matplotlib.Figure instead of pylab.Figure. I switched and the problem still
 occurs. I was curious to see if this problem had to do with how I set up my
 program, not with matplotlib, so I wrote a little test program. The exact
 same problem occurs. I have attached the test program. To see that it does
 work with just one panel comment out lines 39, 41, and 49. When put back
 in, I get the above error message.

 Any suggestions as to how to fix this?

 Thanks!

 Josh






 --
 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




-- 
Daniel Hyams
dhy...@gmail.com
--
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] ANN: mpltools 0.1 release

2012-07-11 Thread Tony Yu
On Wed, Jul 11, 2012 at 11:27 AM, Benjamin Root ben.r...@ou.edu wrote:



 On Wed, Jul 11, 2012 at 11:23 AM, John Hunter jdh2...@gmail.com wrote:



 On Wed, Jul 11, 2012 at 10:09 AM, Damon McDougall 
 damon.mcdoug...@gmail.com wrote:

 Well, as Ben said, that error fill plot is neato! It doesn't look too
 complicated, either. I'd be more than happy to port it over later today
 when I get bored of typing up my thesis. It'll probably only take me
 about 30 minutes.

 If nobody is opposed to this idea, I'll go ahead and submit a PR this
 evening (British Summer (hah!) Time).



 While it is a nice graph, I am not sure that the use case is common
 enough to justify a new plotting method.  One can get the same result with:


   In [68]: x = np.linspace(0, 2 * np.pi)

   In [69]: y_sin = np.sin(x)

   In [70]: err = np.concatenate([y_sin + 0.2, y_sin[::-1] - 0.2])

   In [71]: plot(x, y_sin)
   Out[71]: [matplotlib.lines.Line2D object at 0x96959ec]

   In [72]: fill_between(np.concatenate([x, x[::-1]]), err,
 facecolor='red', alpha=0.5)
   Out[72]: matplotlib.collections.PolyCollection object at 0x962758c

 Admittedly the [::-1] thing is a bit counter-intuitive, but rather than
 adding a new plotting method, perhaps we would be better off with a helper
 method to create the xs and ys for fill_between

   xs, ys = mlab.pad_line(x, y, 0.2)
   fill_between(xs, ys)

 JDH


 At the very least, it should be added to the gallery.  Also, one thing
 that might (or might not) get in the way of getting merged into mainline
 mpl is how well it interacts with legends.  What does it produce in the
 legend?

 Ben Root


As I said before, it is a really simple function: I wrote `errorfill` just
to get an interface that is somewhat similar to `errorbar`. I tend to think
that the Axes object is a bit bloated, so I'm inclined to agree that it
might be best leave it out of matplotlib-proper. +1 on the gallery, though.

Ben: Good point about the legend-interaction. I just added a fix on github;
here's the result:


http://tonysyu.github.com/mpltools/auto_examples/special/plot_errorfill.html

Cheers,
-Tony
--
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] Two panels (wxPython) containing separate figures

2012-07-11 Thread Benjamin Root
On Wed, Jul 11, 2012 at 12:45 PM, Joshua Koehler jjkoehl...@gmail.comwrote:

 Hi all,

 I am currently trying to have two panels each with their own figure
 instance so they can have separate plots.

 I can successfully update a plot if there is only one panel. As soon as I
 add a second panel, I get the following error when I try to update (replot)
 a plot (Showing last message only):

 File
 /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/axes.py,
 line 1374, in _sci
 Argument must be an image, collection, or ContourSet in this Axes)
 ValueError: Argument must be an image, collection, or ContourSet in this
 Axes

 I looked online first and one site suggested it was because I was using
 matplotlib.Figure instead of pylab.Figure. I switched and the problem still
 occurs. I was curious to see if this problem had to do with how I set up my
 program, not with matplotlib, so I wrote a little test program. The exact
 same problem occurs. I have attached the test program. To see that it does
 work with just one panel comment out lines 39, 41, and 49. When put back
 in, I get the above error message.

 Any suggestions as to how to fix this?

 Thanks!

 Josh


Josh,

Can you please post the entire traceback?  My suspicion for what is
happening is that both figures are sharing the same canvas, but I am not
exactly sure.  Anyway, when you perform a plot on one panel, you are
calling clear() for that figure, which may be having side-effects for the
other figure since it is attached to the same Wx object.

Actually, looking over your code again, I see a few things that may or may
not be part of the problem, but should be addressed, nevertheless.  First,
you are calling FigureCanvas and assigning it to self.canvas.  This canvas
is different from the canvas that the figure will actually use, so I am not
sure if this is being done correctly.  Second, your call to plt.close()
assumes that the figure you want to close is the currently active figure.
What you want to call is plt.close(self.figure) in order to make sure it
closes the figure you intend to close.

Ben Root
--
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] Two panels (wxPython) containing separate figures

2012-07-11 Thread Daniel Hyams
Just from morbid curiosity, I installed networkx to see if I could see what
is going on.  And the answer to your original question is that no,
matplotlib doesn't have problems with multiple wx panels; I do this all the
time.

Basically what is going on is that pylab is being used inside of networkx
to issue the plotting commands.  That's a bad idea in general, because of
just this type of situation.  Without getting in there and trying to fix
networkx, I can at least make your script work by inserting this line:

def my_plot(figure):
figure.clear()
plt.figure(figure.number) ---
G = nx.star_graph(15)
axes = figure.add_subplot(1,1,1)
nx.draw_networkx(G, ax=axes)

to make sure that before nx.draw_networkx is invoked, the correct figure is
current.  That's a kludge, but it does work.  The proper solution is to
modify networkx to use the api's properly.  In particular, the glaring one
is right at the top of

site-packages/networkx/drawing/nx_pylab.py, line 119; that

cf = pylab.gcf()

should at least be

if ax is None:
   cf = pylab.gcf()
else:
   cf = ax.get_figure()

[I think]

The above should be reported to the networkx authors.






On Wed, Jul 11, 2012 at 1:02 PM, Daniel Hyams dhy...@gmail.com wrote:

 To get rid of the networkx dependency, I just replaced my_plot() with this:

 def my_plot(figure):
 figure.clear()
 axes = figure.add_subplot(1,1,1)
 axes.plot([0,1,2],[2,3,4])

 and also added self.panel2.update_display() in the constructor for
 MyFrame, and everything worked fine.  Could it be networkx caching a
 reference to a figure or axes that is really the problem?  Can you post the
 full stack trace instead of just the last line?



 On Wed, Jul 11, 2012 at 12:45 PM, Joshua Koehler jjkoehl...@gmail.comwrote:

 Hi all,

 I am currently trying to have two panels each with their own figure
 instance so they can have separate plots.

 I can successfully update a plot if there is only one panel. As soon as I
 add a second panel, I get the following error when I try to update (replot)
 a plot (Showing last message only):

 File
 /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/axes.py,
 line 1374, in _sci
 Argument must be an image, collection, or ContourSet in this Axes)
 ValueError: Argument must be an image, collection, or ContourSet in this
 Axes

 I looked online first and one site suggested it was because I was using
 matplotlib.Figure instead of pylab.Figure. I switched and the problem still
 occurs. I was curious to see if this problem had to do with how I set up my
 program, not with matplotlib, so I wrote a little test program. The exact
 same problem occurs. I have attached the test program. To see that it does
 work with just one panel comment out lines 39, 41, and 49. When put back
 in, I get the above error message.

 Any suggestions as to how to fix this?

 Thanks!

 Josh






 --
 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




 --
 Daniel Hyams
 dhy...@gmail.com




-- 
Daniel Hyams
dhy...@gmail.com
--
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] Two panels (wxPython) containing separate figures

2012-07-11 Thread Joshua Koehler
Here is the full traceback from the sample program:

Traceback (most recent call last):
  File panel_test.py, line 54, in module
frame = MyFrame(None)
  File panel_test.py, line 42, in __init__
self.panel1.update_display()
  File panel_test.py, line 19, in update_display
my_plot(self.figure)
  File panel_test.py, line 10, in my_plot
nx.draw_networkx(G, ax=axes)
  File 
/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/networkx/drawing/nx_pylab.py,
 line 269, in draw_networkx
node_collection=draw_networkx_nodes(G, pos, **kwds)
  File 
/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/networkx/drawing/nx_pylab.py,
 line 392, in draw_networkx_nodes
pylab.sci(node_collection)
  File 
/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/pyplot.py,
 line 226, in sci
gca()._sci(im)
  File 
/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/axes.py,
 line 1374, in _sci
Argument must be an image, collection, or ContourSet in this Axes)
ValueError: Argument must be an image, collection, or ContourSet in this Axes


Thanks guys!

Josh
On Jul 11, 2012, at 1:18 PM, Benjamin Root wrote:

 
 
 On Wed, Jul 11, 2012 at 12:45 PM, Joshua Koehler jjkoehl...@gmail.com wrote:
 Hi all,
 
 I am currently trying to have two panels each with their own figure instance 
 so they can have separate plots.
 
 I can successfully update a plot if there is only one panel. As soon as I add 
 a second panel, I get the following error when I try to update (replot) a 
 plot (Showing last message only):
 
 File 
 /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/axes.py,
  line 1374, in _sci
 Argument must be an image, collection, or ContourSet in this Axes)
 ValueError: Argument must be an image, collection, or ContourSet in this Axes
 
 I looked online first and one site suggested it was because I was using 
 matplotlib.Figure instead of pylab.Figure. I switched and the problem still 
 occurs. I was curious to see if this problem had to do with how I set up my 
 program, not with matplotlib, so I wrote a little test program. The exact 
 same problem occurs. I have attached the test program. To see that it does 
 work with just one panel comment out lines 39, 41, and 49. When put back in, 
 I get the above error message.
 
 Any suggestions as to how to fix this?
 
 Thanks!
 
 Josh
 
 
 Josh,
 
 Can you please post the entire traceback?  My suspicion for what is happening 
 is that both figures are sharing the same canvas, but I am not exactly sure.  
 Anyway, when you perform a plot on one panel, you are calling clear() for 
 that figure, which may be having side-effects for the other figure since it 
 is attached to the same Wx object.
 
 Actually, looking over your code again, I see a few things that may or may 
 not be part of the problem, but should be addressed, nevertheless.  First, 
 you are calling FigureCanvas and assigning it to self.canvas.  This canvas is 
 different from the canvas that the figure will actually use, so I am not sure 
 if this is being done correctly.  Second, your call to plt.close() assumes 
 that the figure you want to close is the currently active figure.  What you 
 want to call is plt.close(self.figure) in order to make sure it closes the 
 figure you intend to close.
 
 Ben Root

--
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] ANN: mpltools 0.1 release

2012-07-11 Thread Damon McDougall
On Wed, Jul 11, 2012 at 10:23:32AM -0500, John Hunter wrote:
 On Wed, Jul 11, 2012 at 10:09 AM, Damon McDougall damon.mcdoug...@gmail.com
  wrote:
 
  Well, as Ben said, that error fill plot is neato! It doesn't look too
  complicated, either. I'd be more than happy to port it over later today
  when I get bored of typing up my thesis. It'll probably only take me
  about 30 minutes.
 
  If nobody is opposed to this idea, I'll go ahead and submit a PR this
  evening (British Summer (hah!) Time).
 
 
 
 While it is a nice graph, I am not sure that the use case is common enough
 to justify a new plotting method.  One can get the same result with:
 
 
   In [68]: x = np.linspace(0, 2 * np.pi)
 
   In [69]: y_sin = np.sin(x)
 
   In [70]: err = np.concatenate([y_sin + 0.2, y_sin[::-1] - 0.2])
 
   In [71]: plot(x, y_sin)
   Out[71]: [matplotlib.lines.Line2D object at 0x96959ec]
 
   In [72]: fill_between(np.concatenate([x, x[::-1]]), err, facecolor='red',
 alpha=0.5)
   Out[72]: matplotlib.collections.PolyCollection object at 0x962758c
 
 Admittedly the [::-1] thing is a bit counter-intuitive, but rather than
 adding a new plotting method, perhaps we would be better off with a helper
 method to create the xs and ys for fill_between
 
   xs, ys = mlab.pad_line(x, y, 0.2)
   fill_between(xs, ys)
 
 JDH

+1 on the helper function. That's probably a much less bloated of way of
doing it.

-- 
Damon McDougall
http://damon-is-a-geek.com
B2.39
Mathematics Institute
University of Warwick
Coventry
West Midlands
CV4 7AL
United Kingdom

--
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] ANN: mpltools 0.1 release

2012-07-11 Thread Benjamin Root
On Wed, Jul 11, 2012 at 11:23 AM, John Hunter jdh2...@gmail.com wrote:



 On Wed, Jul 11, 2012 at 10:09 AM, Damon McDougall 
 damon.mcdoug...@gmail.com wrote:

 Well, as Ben said, that error fill plot is neato! It doesn't look too
 complicated, either. I'd be more than happy to port it over later today
 when I get bored of typing up my thesis. It'll probably only take me
 about 30 minutes.

 If nobody is opposed to this idea, I'll go ahead and submit a PR this
 evening (British Summer (hah!) Time).



 While it is a nice graph, I am not sure that the use case is common enough
 to justify a new plotting method.  One can get the same result with:


   In [68]: x = np.linspace(0, 2 * np.pi)

   In [69]: y_sin = np.sin(x)

   In [70]: err = np.concatenate([y_sin + 0.2, y_sin[::-1] - 0.2])

   In [71]: plot(x, y_sin)
   Out[71]: [matplotlib.lines.Line2D object at 0x96959ec]

   In [72]: fill_between(np.concatenate([x, x[::-1]]), err,
 facecolor='red', alpha=0.5)
   Out[72]: matplotlib.collections.PolyCollection object at 0x962758c

 Admittedly the [::-1] thing is a bit counter-intuitive, but rather than
 adding a new plotting method, perhaps we would be better off with a helper
 method to create the xs and ys for fill_between

   xs, ys = mlab.pad_line(x, y, 0.2)
   fill_between(xs, ys)

 JDH



I could definitely agree with a pad_line() function.  We might want to
revisit the issue of how much visibility the mlab module should get in the
documentation (it currently doesn't get much at all).  My whole take on
mlab was that it was a left-over from the days of working around issues in
NumPy and SciPy and that it was being slowly phased out.  As for other
possible locations, cbook feels like it is more for the devs than for the
users, and adding it to pyplot would render the whole purpose of creating
this function as opposed to errorfill moot.

As an additional point about such a pad_line function, it should probably
be nice to mirror the errorbar() functionality to allow not only a constant
error, but also a N, Nx1, or 2xN array of +/- error. (note that errorbar()
for the 2xN array case does -row1 and +row2).

Cheers!
Ben Root
--
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] Two panels (wxPython) containing separate figures

2012-07-11 Thread Daniel Hyams
Josh:

I'm assuming that you saw the workaround two messages up?

On Wed, Jul 11, 2012 at 1:41 PM, Joshua Koehler jjkoehl...@gmail.comwrote:

 Here is the full traceback from the sample program:

 Traceback (most recent call last):
   File panel_test.py, line 54, in module
 frame = MyFrame(None)
   File panel_test.py, line 42, in __init__
 self.panel1.update_display()
   File panel_test.py, line 19, in update_display
 my_plot(self.figure)
   File panel_test.py, line 10, in my_plot
 nx.draw_networkx(G, ax=axes)
   File
 /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/networkx/drawing/nx_pylab.py,
 line 269, in draw_networkx
 node_collection=draw_networkx_nodes(G, pos, **kwds)
   File
 /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/networkx/drawing/nx_pylab.py,
 line 392, in draw_networkx_nodes
 pylab.sci(node_collection)
   File
 /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/pyplot.py,
 line 226, in sci
 gca()._sci(im)
   File
 /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/axes.py,
 line 1374, in _sci
 Argument must be an image, collection, or ContourSet in this Axes)
 ValueError: Argument must be an image, collection, or ContourSet in this
 Axes


 Thanks guys!

 Josh
 On Jul 11, 2012, at 1:18 PM, Benjamin Root wrote:



 On Wed, Jul 11, 2012 at 12:45 PM, Joshua Koehler jjkoehl...@gmail.comwrote:

 Hi all,

 I am currently trying to have two panels each with their own figure
 instance so they can have separate plots.

 I can successfully update a plot if there is only one panel. As soon as I
 add a second panel, I get the following error when I try to update (replot)
 a plot (Showing last message only):

 File
 /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/matplotlib/axes.py,
 line 1374, in _sci
 Argument must be an image, collection, or ContourSet in this Axes)
 ValueError: Argument must be an image, collection, or ContourSet in this
 Axes

 I looked online first and one site suggested it was because I was using
 matplotlib.Figure instead of pylab.Figure. I switched and the problem still
 occurs. I was curious to see if this problem had to do with how I set up my
 program, not with matplotlib, so I wrote a little test program. The exact
 same problem occurs. I have attached the test program. To see that it does
 work with just one panel comment out lines 39, 41, and 49. When put back
 in, I get the above error message.

 Any suggestions as to how to fix this?

 Thanks!

 Josh


 Josh,

 Can you please post the entire traceback?  My suspicion for what is
 happening is that both figures are sharing the same canvas, but I am not
 exactly sure.  Anyway, when you perform a plot on one panel, you are
 calling clear() for that figure, which may be having side-effects for the
 other figure since it is attached to the same Wx object.

 Actually, looking over your code again, I see a few things that may or may
 not be part of the problem, but should be addressed, nevertheless.  First,
 you are calling FigureCanvas and assigning it to self.canvas.  This canvas
 is different from the canvas that the figure will actually use, so I am not
 sure if this is being done correctly.  Second, your call to plt.close()
 assumes that the figure you want to close is the currently active figure.
 What you want to call is plt.close(self.figure) in order to make sure it
 closes the figure you intend to close.

 Ben Root




 --
 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




-- 
Daniel Hyams
dhy...@gmail.com
--
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


[Matplotlib-users] How to compile under windows?

2012-07-11 Thread Daniel Hyams
I looked around in the docs a bit but didn't find anything...is there a
guide / set of recommended practices when trying to build matplotlib from
source on Windows?

-- 
Daniel Hyams
dhy...@gmail.com
--
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] How to compile under windows?

2012-07-11 Thread Christoph Gohlke
On 7/11/2012 1:47 PM, Daniel Hyams wrote:
 I looked around in the docs a bit but didn't find anything...is there a
 guide / set of recommended practices when trying to build matplotlib
 from source on Windows?


These discussions on [matplotlib-devel] might help:

Calling all Mac OSX users!
http://sourceforge.net/mailarchive/message.php?msg_id=27950397

Building on Windows (Was Re: Calling all Mac OSX users!)
http://sourceforge.net/mailarchive/message.php?msg_id=27961105

- Christoph

--
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] ANN: mpltools 0.1 release

2012-07-11 Thread Tony Yu
On Wed, Jul 11, 2012 at 2:28 PM, Benjamin Root ben.r...@ou.edu wrote:



 On Wed, Jul 11, 2012 at 11:23 AM, John Hunter jdh2...@gmail.com wrote:



 On Wed, Jul 11, 2012 at 10:09 AM, Damon McDougall 
 damon.mcdoug...@gmail.com wrote:

 Well, as Ben said, that error fill plot is neato! It doesn't look too
 complicated, either. I'd be more than happy to port it over later today
 when I get bored of typing up my thesis. It'll probably only take me
 about 30 minutes.

 If nobody is opposed to this idea, I'll go ahead and submit a PR this
 evening (British Summer (hah!) Time).



 While it is a nice graph, I am not sure that the use case is common
 enough to justify a new plotting method.  One can get the same result with:


   In [68]: x = np.linspace(0, 2 * np.pi)

   In [69]: y_sin = np.sin(x)

   In [70]: err = np.concatenate([y_sin + 0.2, y_sin[::-1] - 0.2])

   In [71]: plot(x, y_sin)
   Out[71]: [matplotlib.lines.Line2D object at 0x96959ec]

   In [72]: fill_between(np.concatenate([x, x[::-1]]), err,
 facecolor='red', alpha=0.5)
   Out[72]: matplotlib.collections.PolyCollection object at 0x962758c

 Admittedly the [::-1] thing is a bit counter-intuitive, but rather than
 adding a new plotting method, perhaps we would be better off with a helper
 method to create the xs and ys for fill_between

   xs, ys = mlab.pad_line(x, y, 0.2)
   fill_between(xs, ys)

 JDH



 I could definitely agree with a pad_line() function.  We might want to
 revisit the issue of how much visibility the mlab module should get in the
 documentation (it currently doesn't get much at all).  My whole take on
 mlab was that it was a left-over from the days of working around issues in
 NumPy and SciPy and that it was being slowly phased out.  As for other
 possible locations, cbook feels like it is more for the devs than for the
 users, and adding it to pyplot would render the whole purpose of creating
 this function as opposed to errorfill moot.

 As an additional point about such a pad_line function, it should probably
 be nice to mirror the errorbar() functionality to allow not only a constant
 error, but also a N, Nx1, or 2xN array of +/- error. (note that errorbar()
 for the 2xN array case does -row1 and +row2).


Damon: it sounds like you're volunteering to submit a PR to add this
function ;)

Here's the relevant bit (which should already handle the cases Ben mentions
above):


https://github.com/tonysyu/mpltools/blob/master/mpltools/special/errorfill.py#L54

It needs a docstring and a home (pyplot.py?). I kind of think `offset_line`
is more explicit than `pad_line` (both of these are *much* better than my
original `extrema_from_error_input`).

Cheers,
-Tony


 Cheers!
 Ben Root


--
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


[Matplotlib-users] (no subject)

2012-07-11 Thread Arek Kedzior
http://horit.com/yuaoqlcns/405279.html--
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