[Matplotlib-users] pylab mode with PySide 1.10 segfaults on Linux

2012-03-24 Thread Wes McKinney
Has anyone had much luck with PySide + matplotlib 1.1.0+? With stock
EPD 7.2 full on Ubuntu 10.04 which comes with PySide 1.1.0, a simple
plot like plot(arange(10)) with IPython in pylab mode causes a
segfault. Joy.

Thanks,
Wes

--
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Unit testing code that generate matplotlib plots

2011-11-02 Thread Wes McKinney
On Wed, Nov 2, 2011 at 5:43 PM, Wes McKinney  wrote:
> On Wed, Nov 2, 2011 at 5:20 PM, John Hunter  wrote:
>> On Wed, Nov 2, 2011 at 4:16 PM, Wes McKinney  wrote:
>>> Hi guys,
>>>
>>> Is there a common practice for unit testing code that creates
>>> matplotlib plots? I'm mainly just interested in code coverage versus
>>> correctness (making sure the code *works*) for now. I guess one way
>>> would be to disable the GUI backend so GUI elements don't get created
>>> (if the user is running the test suite from inside IPython in pylab
>>> mode, for example). Any tips or pointers to projects that do this
>>> would be very helpful.
>>
>> We have a unit testing framework for comparing images against baseline
>> images using PIL to compare "approximately close" at the rendering
>> level.  The code lives in matplotlib.testing and is triggered by
>> matplotlib.test.
>>
>> It might be heavyweight for what you want, so if all you want to do is
>> insure "it runs" just create some figures using the agg backend and
>> call savefig.  You can use the pyplot.switch_backends to switch
>> backends if you are concerned about a user calling it from ipython in
>> an interactive session.
>>
>> JDH
>>
>> JDH
>>
>
> Cool, I think then just using switch_backends is what I want-- switch
> to Agg in setUpClass and switch back to whatever backend was in use
> before in tearDownClass. Will report back with any problems.
>
> thanks,
> Wes
>

switch_backends appears to have no effect on OS X / mpl 1.0.1. Has
this been worked on in matplotlib 1.1.0? I can always just skip MPL
unit tests if the user if IPython is running and call mpl.use('Agg')
otherwise.

--
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Unit testing code that generate matplotlib plots

2011-11-02 Thread Wes McKinney
On Wed, Nov 2, 2011 at 5:20 PM, John Hunter  wrote:
> On Wed, Nov 2, 2011 at 4:16 PM, Wes McKinney  wrote:
>> Hi guys,
>>
>> Is there a common practice for unit testing code that creates
>> matplotlib plots? I'm mainly just interested in code coverage versus
>> correctness (making sure the code *works*) for now. I guess one way
>> would be to disable the GUI backend so GUI elements don't get created
>> (if the user is running the test suite from inside IPython in pylab
>> mode, for example). Any tips or pointers to projects that do this
>> would be very helpful.
>
> We have a unit testing framework for comparing images against baseline
> images using PIL to compare "approximately close" at the rendering
> level.  The code lives in matplotlib.testing and is triggered by
> matplotlib.test.
>
> It might be heavyweight for what you want, so if all you want to do is
> insure "it runs" just create some figures using the agg backend and
> call savefig.  You can use the pyplot.switch_backends to switch
> backends if you are concerned about a user calling it from ipython in
> an interactive session.
>
> JDH
>
> JDH
>

Cool, I think then just using switch_backends is what I want-- switch
to Agg in setUpClass and switch back to whatever backend was in use
before in tearDownClass. Will report back with any problems.

thanks,
Wes

--
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Unit testing code that generate matplotlib plots

2011-11-02 Thread Wes McKinney
Hi guys,

Is there a common practice for unit testing code that creates
matplotlib plots? I'm mainly just interested in code coverage versus
correctness (making sure the code *works*) for now. I guess one way
would be to disable the GUI backend so GUI elements don't get created
(if the user is running the test suite from inside IPython in pylab
mode, for example). Any tips or pointers to projects that do this
would be very helpful.

Thanks,
Wes

--
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] use $1 for name of file plt.savefig

2011-04-28 Thread Wes McKinney
On Thu, Apr 28, 2011 at 1:01 PM, Wes McKinney  wrote:
> On Thu, Apr 28, 2011 at 12:55 PM, Pau  wrote:
>> Hi,
>>
>> I am trying to use recursively a matplotlib script to create 650 plots.
>>
>> For this, I have defined
>>
>> cluster = loadtxt(sys.argv[1])
>> MBH     = loadtxt ('./TrajectoryMBH.asc')
>>
>> X_cl = cluster[:, 2]  # Column 3
>> Y_cl = cluster[:, 3]  # Column 4
>> Z_cl = cluster[:, 4]  # Column 5
>>
>> X_mbh = MBH[:, 2]  # Column 3
>> Y_mbh = MBH[:, 3]  # Column 4
>> Z_mbh = MBH[:, 4]  # Column 5
>>
>>
>> because "cluster" is the file that changes. TrajectoryMBH.asc is
>> always the same file for all 650 plots
>>
>> This way, I can run
>>
>> ./Hit_Cluster_MBH.py MYFILE_001.dat
>>
>> and the script takes MYFILE_001.dat as "cluster".
>>
>> Now, I would like matplotlib to produce the eps file automatically,
>> without any popup window.
>>
>> For this, I usually define
>>
>> import matplotlib
>> matplotlib.use('Agg')
>> import matplotlib.pyplot as plt
>>
>> and the, at the very bottom, instead of
>>
>> show()
>>
>> I have
>>
>> plt.savefig('MyEPS.eps')
>>
>> What I would like though is that matplotlib produces automatically
>>
>> MYFILE_001.eps
>> MYFILE_002.eps
>>
>> etc
>>
>> when running the python script within a shell script such as
>>
>> for file in $(ls *dat) ; do ; ./Hit_Cluster_MBH.py $file ; done
>>
>> but I do not know how to do this in the
>>
>> plt.savefig('MyEPS.eps')
>>
>> part...
>>
>> Obviously
>>
>> plt.savefig('$file.eps')
>>
>> does not work.
>>
>> Any hint will be appreciated.
>>
>> Thanks,
>>
>> Pau
>>
>> --
>> WhatsUp Gold - Download Free Network Management Software
>> The most intuitive, comprehensive, and cost-effective network
>> management toolset available today.  Delivers lowest initial
>> acquisition cost and overall TCO of any competing solution.
>> http://p.sf.net/sfu/whatsupgold-sd
>> ___
>> Matplotlib-users mailing list
>> Matplotlib-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>
> How about something like:
>
> name, ext = sys.argv[1].split('.')
> plt.savefig('%s.eps' % name)
>

Also, if you do everything in Python instead of a shell script, the
whole process will take much less time. E.g.:

def generate_eps_file(pth):
...
# generate your plot from specified file
name, ext = pth.split('.')
plt.savefig('%s.eps' % name)

import glob
files = glob.glob('*.dat')

for filepath in files:
generate_eps_file(filepath)

--
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network 
management toolset available today.  Delivers lowest initial 
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] use $1 for name of file plt.savefig

2011-04-28 Thread Wes McKinney
On Thu, Apr 28, 2011 at 12:55 PM, Pau  wrote:
> Hi,
>
> I am trying to use recursively a matplotlib script to create 650 plots.
>
> For this, I have defined
>
> cluster = loadtxt(sys.argv[1])
> MBH     = loadtxt ('./TrajectoryMBH.asc')
>
> X_cl = cluster[:, 2]  # Column 3
> Y_cl = cluster[:, 3]  # Column 4
> Z_cl = cluster[:, 4]  # Column 5
>
> X_mbh = MBH[:, 2]  # Column 3
> Y_mbh = MBH[:, 3]  # Column 4
> Z_mbh = MBH[:, 4]  # Column 5
>
>
> because "cluster" is the file that changes. TrajectoryMBH.asc is
> always the same file for all 650 plots
>
> This way, I can run
>
> ./Hit_Cluster_MBH.py MYFILE_001.dat
>
> and the script takes MYFILE_001.dat as "cluster".
>
> Now, I would like matplotlib to produce the eps file automatically,
> without any popup window.
>
> For this, I usually define
>
> import matplotlib
> matplotlib.use('Agg')
> import matplotlib.pyplot as plt
>
> and the, at the very bottom, instead of
>
> show()
>
> I have
>
> plt.savefig('MyEPS.eps')
>
> What I would like though is that matplotlib produces automatically
>
> MYFILE_001.eps
> MYFILE_002.eps
>
> etc
>
> when running the python script within a shell script such as
>
> for file in $(ls *dat) ; do ; ./Hit_Cluster_MBH.py $file ; done
>
> but I do not know how to do this in the
>
> plt.savefig('MyEPS.eps')
>
> part...
>
> Obviously
>
> plt.savefig('$file.eps')
>
> does not work.
>
> Any hint will be appreciated.
>
> Thanks,
>
> Pau
>
> --
> WhatsUp Gold - Download Free Network Management Software
> The most intuitive, comprehensive, and cost-effective network
> management toolset available today.  Delivers lowest initial
> acquisition cost and overall TCO of any competing solution.
> http://p.sf.net/sfu/whatsupgold-sd
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>

How about something like:

name, ext = sys.argv[1].split('.')
plt.savefig('%s.eps' % name)

--
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network 
management toolset available today.  Delivers lowest initial 
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] TkAgg backend error message running within IPython

2010-10-01 Thread Wes McKinney
I'm getting the error:

can't invoke "event" command:  application has been destroyed
while executing
"event generate $w <>"
(procedure "ttk::ThemeChanged" line 6)
invoked from within
"ttk::ThemeChanged"

With the latest matplotlib 1.0.0 on 64-bit Ubuntu 10.04 running the
following script within IPython 0.10 in pylab mode:

import matplotlib.pyplot as plt
import numpy as np

def test():
plt.figure(figsize=(10,5))
plt.plot(np.arange(1, 51), np.arange(1, 51), color='k')

def make_figs():
test()
plt.savefig('foo.pdf')
plt.close('all')

if __name__ == '__main__':
make_figs()

Here's the build information:

w...@wesm-desktop:~/code/repos/matplotlib$ sudo python setupegg.py develop
basedirlist is: ['/usr/local', '/usr']

BUILDING MATPLOTLIB
matplotlib: 1.0.0
python: 2.6.5 |EPD 6.2-2 (64-bit)| (r265:79063, Mar 22 2010,
17:32:05)  [GCC 4.1.2 20080704 (Red Hat 4.1.2-44)]
  platform: linux2

REQUIRED DEPENDENCIES
 numpy: 1.4.0
 freetype2: 9.22.3

OPTIONAL BACKEND DEPENDENCIES
libpng: 1.2.42
   Tkinter: Tkinter: 73770, Tk: 8.5, Tcl: 8.5
* Guessing the library and include directories for
* Tcl and Tk because the tclConfig.sh and
* tkConfig.sh could not be found and/or parsed.
  Gtk+: no
* Building for Gtk+ requires pygtk; you must be able
* to "import gtk" in your build/install environment
   Mac OS X native: no
Qt: no
   Qt4: no
 Cairo: no

OPTIONAL DATE/TIMEZONE DEPENDENCIES
  datetime: present, version unknown
  dateutil: 1.5
  pytz: 2010h

OPTIONAL USETEX DEPENDENCIES
dvipng: 1.12
   ghostscript: 8.71
 latex: 3.1415926
   pdftops: 0.12.4

[Edit setup.cfg to suppress the above messages]

I checked that EPD 6.2.2 was built with tk8.5/tcl8.5 in case that was
causing a problem, does not seem to be.

I can switch to the WXAgg backend for now, but would help to know if
I'm doing something wrong by chance.

Note: I do not get this message running the script standalone outside
of IPython!

Thanks,
Wes

--
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users