Re: memory error with matplot

2006-12-07 Thread John Hunter
 lisa == lisa engblom [EMAIL PROTECTED] writes:

lisa Hi, I am using matplotlib with python to generate a bunch of
lisa charts.  My code works fine for a single iteration, which
lisa creates and saves 4 different charts.  The trouble is that
lisa when I try to run it for the entire set (about 200 items) it
lisa can run for 12 items at a time.  On the 13th, I get an error
lisa from matplotlib that says it can't access data.  However, if
lisa I start the program at the point it failed before it works
lisa fine and will create the charts for the next 12 before
lisa failing.  I assume that I am not closing the files properly
lisa somehow or otherwise misallocating memory.  I tried just
lisa reimporting pylab each iteration, but that didn't help.
lisa This is the function that creates a chart:

There are a couple of things to try.  First, on a long shot, does it
help to do

  close(1)

instead if simply close().  I don't think it will but worth a try.

Second, I think there is a small leak in the tkcanvas, but not in
matplotlib proper.  Do you need to display the graphs you are
creating, or do you merely want to save them?  If the latter, simply
use the Agg backend 

import matplotlib
matplotlib.use('Agg')

*before* you import pylab.

Finally, if you are still having troubles, post a complete,
free-standing, script to the matplotlib mailing list and we'll see if
we can replicate it.

You may also want to take a look at the FAQ on memory leaks:

http://matplotlib.sourceforge.net/faq.html#LEAKS

JDH
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Global module variables as default parameters

2006-09-22 Thread John Hunter
 Christoph == Christoph Haas [EMAIL PROTECTED] writes:

Christoph Hi, list...  I wondered if it's possible to use global
Christoph (module) variables as default parameters. A simple
Christoph working example:

Christoph 
Christoph #!/usr/bin/python

Christoph globalvar = 123

Christoph def test(foo=globalvar): print foo

kwargs defaults are initialized a module load time, not at function
call time.  The standard idiom is

def test(foo=None): 
if foo is None: foo = globalvar
print foo

JDH
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: newbie graphing recommendations ?

2006-07-17 Thread John Hunter
 bearophileHUGS == bearophileHUGS  [EMAIL PROTECTED] writes:

bearophileHUGS I think MatPlotLib can do this too, if your
bearophileHUGS computer is fast enough.

 i would also like to have the bars and graphs have nice shading
 if possible to give it a really attractive look.

bearophileHUGS Remember what Edward Tufte (www.edwardtufte.com)
bearophileHUGS says, often too much elaborations makes graphs
bearophileHUGS them less than useless.

I share Tufte's opinion that you should avoid chart-junk -- stuff
designed to make charts look sexier that don't add information
context.  matplotlib can do it (but doesn't go out of it's way to make
it easy).  Eg,

from pylab import figure, show, nx, cm

def gbar(ax, x, y, width=0.5, bottom=0):
X = [[.6, .6],[.7,.7]]
for left,top in zip(x, y):
right = left+width
ax.imshow(X, interpolation='bicubic', cmap=cm.Blues,
  extent=(left, right, bottom, top), alpha=1)

fig = figure()

xmin, xmax = xlim = 0,10
ymin, ymax = ylim = 0,1
ax = fig.add_subplot(111, xlim=xlim, ylim=ylim,
 autoscale_on=False)
X = [[.6, .6],[.7,.7]]

ax.imshow(X, interpolation='bicubic', cmap=cm.copper,
  extent=(xmin, xmax, ymin, ymax), alpha=1)

N = 10
x = nx.arange(N)+0.25
y = nx.mlab.rand(N)
gbar(ax, x, y, width=0.7)
ax.set_aspect('normal')
show()
-- 
http://mail.python.org/mailman/listinfo/python-list


tk filesave dialog triggers unexpected destroy event

2006-07-09 Thread John Hunter

The following behavior surprised me.  I have a Tk window and launch a
file save dialog from it.  When the filesave dialog is finished, it
calls callbacks bound to the destroy event on the main window.  Is
this expected, and can I avoid this?

To expose the problem, run this script and click the mouse button over
the application window.  When the file save dialog is through, the
function callback is called, which I did not expect because I bound
this callback to the window destroy event.

Thanks for any advice.  Using Tk 1.177

JDH

import Tkinter as Tk
from tkFileDialog import asksaveasfilename

def button(event):
fname = asksaveasfilename(
title='Save the figure'
)




window = Tk.Tk()
frame = Tk.Frame(window, width=500,height=500)
frame.bind('Button-1', button)
frame.pack()


def callback(*args):
print 'called callback'
window.bind(Destroy, callback)

window.mainloop()


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: image output in matplotlib

2006-07-03 Thread John Hunter
 mart == mart jeeha [EMAIL PROTECTED] writes:

mart Hey folks, I got a problem in printing images from a
mart matplotlib - FigureCanvas Object (child of a wxFrame,
mart library backend_wx) into jpeg-formatted files. (I like to
mart create a sequence of images that I can assemble to an avi)
mart self.mycanvas.print_figure(test.jpg) merely gives an error
mart stating, that there should be an image handler of type 17,
mart which I didn't come across ever :)

Was your wx built with jpeg support?  You might try png, which
matplotlib supports natively.

JDH

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: numeric/numpy/numarray

2006-06-13 Thread John Hunter
 Bryan == Bryan  [EMAIL PROTECTED] writes:

Bryan hi, what is the difference among numeric, numpy and
Bryan numarray?  i'm going to start using matplotlib soon and i'm
Bryan not sure which one i should use.

numpy is the successor to numarray and Numeric.  All three do
basically the same thing.  You should use numpy.

matplotlib works with all three, you just need to be sure to set your
numerix setting to numpy in your matplotlibrc file.

numerix  : numpy  # numpy, Numeric or numarray

On unix like OSes, this file is placed in ~/.matplotlib.  On windows
systems, it is usually found in C:\Documents and
Settings\yourname\.matplotlib

JDH
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how not to run out of memory in cursor.execute

2006-06-07 Thread John Hunter
 [EMAIL PROTECTED] == [EMAIL PROTECTED] com [EMAIL PROTECTED] writes:

[EMAIL PROTECTED] whenever you are using a package that leaks memory.
[EMAIL PROTECTED] it can be appropriate to use Rpyc
[EMAIL PROTECTED] (http://rpyc.wikispaces.com/) to run the leaking
[EMAIL PROTECTED] code in a different process, and restart it from
[EMAIL PROTECTED] time to time.  I've been using this method to avoid
[EMAIL PROTECTED] the leaks of matplotlib.

The only known leak in matplotlib is in the tkagg backend which we
believe comes from tkinter and is not in matplotlib proper.  There are
a variety of ways to make it look like matplotlib is leaking memory,
eg overplotting when you want to first clear the plot, or failing to
close figures properly.  We have unit tests to check for leaks, and
they are passing.  Perhaps you can post some code which exposes the
problem.

JDH 
-- 
http://mail.python.org/mailman/listinfo/python-list


curses event handling

2006-06-07 Thread John Hunter

I have a curses app that is displaying real time data.  I would like
to bind certain keys to certain functions, but do not want to block
waiting for 
 
  c = screen.getch() 

Is it possible to register callbacks with curses, something like

  screen.register('keypress', myfunc)

Thanks,
JDH
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: two of pylab.py

2006-05-09 Thread John Hunter
 Diez == Diez B Roggisch [EMAIL PROTECTED] writes:

 I use debian/testing linux Linux debian/testing 2.6.15-1-686
 
 I found some duplicate files in my system, I don't if the are
 both needed, should I delete one of the groups below and which
 one?

site-packages/pylab.py is just there for convenience to import
matplotlib.pylab, since it is easier to type

import pylab

rather than

import matplotlib.pylab

You should leave all of the file as is, because code will assume both
are there.

JDH
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Non-web-based templating system

2006-05-01 Thread John Hunter
 Alex == Alex Martelli [EMAIL PROTECTED] writes:

Alex I have a certain fondness for the first over-100-lines
Alex module I wrote for Python, which eventually resulted in:

As well you should!  YAPTU powers the entire matplotlib website
(screenshots, FAQ, what's new, etc), as evidenced by the Powered by
YAPTU co-branding on the bottom of every page

  http://matplotlib.sf.net

with src (*.html.template) at

  http://svn.sourceforge.net/viewcvs.cgi/matplotlib/trunk/htdocs/

I must confess though that the prehistoric YAPTU version I use comes
in at only 78 lines, so it is clearly time for me to upgrade.  I rely
on it so much I even wrote a debian ubuntu package for local use, as
twisted as that may seem.  I definitely need to check out the latest
version!

JDH

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Events in Python?

2006-04-26 Thread John Hunter
 redefined == redefined horizons [EMAIL PROTECTED] writes:

redefined Here is another non-pythonic question from the Java
redefined Developer. (I beg for forgiveness...)

redefined Does Python have a mechanism for events/event-driven
redefined programming?

The enthought traits package has built-in support for event handling,
among other things

  http://code.enthought.com/traits/

Here is an example from the web page:

from enthought.traits import Delegate, HasTraits, Int, Str, Instance 
from enthought.traits.ui import View, Item

class Parent(HasTraits):
first_name = Str('') # INITIALIZATION:
last_name = Str('')  # 'first_name' and
 # 'last_name' are
 # initialized to ''
class Child(HasTraits):
age = Int

father = Instance(Parent)  # VALIDATION: 'father' must
   # be a Parent instance

first_name = Str('')

last_name = Delegate('father') # DELEGATION:
   # 'last_name' is
   # delegated to
   # father's 'last_name'

def _age_changed(self, old, new):  # NOTIFICATION:
   # This method is
   # called when 'age'
   # changes
print 'Age changed from %s to %s ' % (old, new)


  
traits_view = View(Item(name='first_name'),   # TRAITS UI: Define
   Item(name='last_name', # the default window
style='readonly'),# layout
   Item(name='age'),
   Item(name='father'))



# Make and manipulate objects from the classes above


joe = Parent()
joe.last_name = 'Johnson'

# DELEGATION in action
moe = Child()
moe.father = joe
print Moe's last name is %s % (moe.last_name)

# NOTIFICATION in action
moe.age = 10

#VISUALIZATION: Display the UI
moe.configure_traits()

The DELEGATION and NOTIFICATION segments in the above example yield
the following command-line output:

Moe's last name is Johnson
Age changed from 0 to 10
  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Plotting package?

2006-04-25 Thread John Hunter
 Andrew == Andrew Koenig [EMAIL PROTECTED] writes:

Andrew This may be a foolish question, but what's the most
Andrew straightforward way to plot a bunch of data in Python?


in matplotlib/pylab

  from pylab import figure, show
  x = range(10)
  y = [val**2 for val in x]
  fig = figure()
  ax = fig.add_subplot(111)
  ax.plot(x,y)
  ax.set_title('My first plot')
  ax.set_xlabel('x')
  ax.set_ylabel('y')
  show()

Tutorial: http://matplotlib.sourceforge.net/tutorial.html
Screenshots: http://matplotlib.sourceforge.net/screenshots.html

JDH

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Phython and graphing

2006-04-20 Thread John Hunter
 mostro == mostro  [EMAIL PROTECTED] writes:

mostro Hello, Can someone lead me to an easy way to create a
mostro graph in Python.

mostro For example, I have a script running that creates a list
mostro of dates, times and values. I would like to turn this into
mostro a graph.

mostro I can grep the info into a new file creating two columns
mostro (x,y) but the issue is the graph.

mostro P.S. I'm a Python newbie so keep that in mind.

Here's an example from the matplotlib examples dir

  http://matplotlib.sf.net/examples

that does just that.  It loads dates and values from a file using the
load function, and then plots them with the plot_date command

The delimiter directive in the load command says to use comma
separated values.  The converters arg is a dictionary mapping column
number to a function that converts that column to a float (datestr2num
converts date strings to matplotlib dates using the wonderful
dateutil.parser.parse function that can convert just about any date
string -- the default column converter is 'float').  skiprows
indicates that there is a single line of header to convert, and
usecols says to take the first and third columns.

The rest is easy -- just call plot_dates:

from pylab import figure, show, datestr2num, load
dates, closes = load(
'data/msft.csv', delimiter=',',
converters={0:datestr2num}, skiprows=1, usecols=(0,2),
unpack=True)

fig = figure()
ax = fig.add_subplot(111)
ax.plot_date(dates, closes)
show()


Here is a brief look at the data file being plotted:

Date,Open,High,Low,Close,Volume,Adj. Close*
19-Sep-03,29.76,29.97,29.52,29.96,92433800,29.79
18-Sep-03,28.49,29.51,28.42,29.50,67268096,29.34
17-Sep-03,28.76,28.95,28.47,28.50,47221600,28.34
16-Sep-03,28.41,28.95,28.32,28.90,52060600,28.74
15-Sep-03,28.37,28.61,28.33,28.36,41432300,28.20
 and many more


JDH
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Using Python To Create An Encrypted Container

2006-04-17 Thread John Hunter
 Michael == Michael Sperlle [EMAIL PROTECTED] writes:

Michael Is it possible? Bestcrypt can supposedly be set up on
Michael linux, but it seems to need changes to the kernel before
Michael it can be installed, and I have no intention of going
Michael through whatever hell that would cause.

Michael If I could create a large file that could be encrypted,
Michael and maybe add files to it by appending them and putting
Michael in some kind of delimiter between files, maybe a homemade
Michael version of truecrypt could be constructed.

One problem in using a large file which is encrypted is that a single
byte error can destroy all your data (see DEDICATION below).  I wrote
a little python module called hashtar that works like tar, but
encrypts every file independently in a flattened dir structure with
filename hiding.  It stores the file permissions, dir structure, and
ownership in an encrypted header of each encrypted file after first
padding some random data at the top to reduce the risk of known
plaintext attacks.

Here is some example usage

 hashtar.py -cvf numeric.htar numeric
Password:
Confirm:
numeric/__init__.py - numeric.htar/1a/1a9f48d439144d1fa33b186fa49a6b63
numeric/contiguous_demo.py - 
numeric.htar/8a/8a7757bf6f4a20e6904173f7c597eb45
numeric/diff_dmo.py - numeric.htar/0c/0cea827761aef0ccfc55a869dd2aeb38
numeric/fileio.py - numeric.htar/3e/3e50f59a1d2d87307c585212fb84be6a
numeric/find - numeric.htar/b1/b1070de08f4ea531f10abdc58cfe8edc
...snip

 find numeric.htar|head
numeric.htar
numeric.htar/1a
numeric.htar/1a/1a9f48d439144d1fa33b186fa49a6b63
numeric.htar/8a
numeric.htar/8a/8a7757bf6f4a20e6904173f7c597eb45
numeric.htar/8a/8a4343ba60feda855fbaf8132e9b5a6b
numeric.htar/8a/8a72457096828c8d509ece6520e49d0b
numeric.htar/0c
numeric.htar/0c/0cea827761aef0ccfc55a869dd2aeb38
numeric.htar/3e


 hashtar.py -tvf numeric.htar
Password:
131 numeric/__init__.py
594 numeric/contiguous_demo.py
26944   numeric/Quant.pyc
209 numeric/extensions/test/rpm_build.sh
230 numeric/diff_dmo.py
439 numeric/fileio.py

It works across platforms (win32, OSX and linux tested), so files
encrypted on one will decrypt on others.

All the code lives in a single file (hashtar.py) included below.

See also the WARNING below (hint -- I am not a cryptographer)

#!/usr/bin/env python

OVERVIEW

  hashtar: an encrypted archive utility designed for secure archiving
  to media vulnerable to corruption.

  Recursively encrypt the files and directories passed as arguments.
  Rather than preserving the directory structure, or archiving to a
  single file as in tar, the files are encrypted to a single dir and
  named with the hash of their relative path.  The file information
  (filename, permission mode, uid, gid) is encrypted and stored in the
  header of the file itself, and can be used to restore the original
  file with dir structure from the archive file.  For example, the
  command

 hashtar.py -cvf tmp.htar finance/

  prompts for a password and generates an encrypted recursive archive
  of the finance dir in the tmp.htar dir, with filenames mapped like

finance/irs/98/f1040.pdf - tmp.htar/e5/e5ed546c0bc0191d80d791bc2f73c890
finance/sale_house/notes - tmp.htar/58/580e89bad7563ae76c295f75aecea030
finance/online/accounts.gz.mcr - 
tmp.htar/bb/bbf12f06dc3fcee04067d40b9781f4a8
finance/phone/prepaid1242.doc - 
tmp.htar/c1/c1fe52a9d8cbef55eff8840d379d972a

  The encrypted files are placed in subdirs based on the first two
  characters in their hash name because if too many files are placed
  in one dir, it may not be possible to pass all of them as command
  line arguments to the restore command.  The entire finance dir
  structure can later be restored with
 
 hashtar.py -xvf tmp.htar

  The advantage of this method of encrypted archiving, as opposed to
  archiving to a single tar file and encrypting it, is that this
  method is not sensitive to single byte corruption, which becomes
  important especially on externally stored archives, such as on CDR,
  or DVDR.  Any individual file contains all the information needed to
  restore itself, with directory structure, permission bits, etc.  So
  only the specific files that are corrupted on the media will be
  lost.

  The alternative strategy, encrypting all the files in place and then
  archiving to external media, doesn't suffer from single byte
  corruption but affords less privacy since the filenames, dir
  structure, and permission bits are available, and less security
  since a filename may indicate contents and thus expose the archive
  to a known plaintext attack.

  A match string allows you to only extract files matching a given
  pattern.  Eg, to only extract pdf and xls files, do

hashtar.py -m pdf,xls -xvf tmp.htar

  Because the filenames are stored in the header, only a small 

Re: Calling Python from Matlab

2006-04-17 Thread John Hunter
 AgenteSegreto == AgenteSegreto  [EMAIL PROTECTED] writes:

AgenteSegreto I've been a Matlab user for years and have recently
AgenteSegreto started using Python with matplotlib and NumPy for
AgenteSegreto most of my work.  The only thing I found that is
AgenteSegreto still lacking is a 3D capability in matplotlib.  I

There is some progress being made on this front -- in svn are a
collection of classes for basic 3d plots (plot3, mesh, surf) but the
interface to these is still under development.  We hope they will be
included in the next major release 0.88.

You can see some examples here:

  http://www.scipy.org/Wiki/Cookbook/Matplotlib/mplot3D

Also, there is a master's student who will be working on extending mpl
3d capabilities as part of her master's project, so expect some basic
functionality in the near future.  

We certainly don't aim to compete with VTK or other full-blown 3D
solutions like Mayavi

  http://mayavi.sourceforge.net/
  http://www.enthought.com/enthought/wiki/MayaVi
  http://www.scipy.org/ArndBaecker/MayaVi2
  
but most agree it would be nice to have some support for basic 3D
plotting in matplotlib.

JDH
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: can I get the index number in for x in y loop?

2006-04-03 Thread John Hunter
 Scott == Scott David Daniels [EMAIL PROTECTED] writes:

Scott  I cannot find the distance in meters between Paris and
Scott London with: for i in range(10): print i

Works for me

def range(x):
yield '332.8 km'

for i in range(10):
print i

...may not be considered best practice, though wink

JDH

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Matplotlib: How to set number of ticks on an axis?

2006-03-30 Thread John Hunter
 Caleb == Caleb Hattingh [EMAIL PROTECTED] writes:

Caleb It seems that the locater() classes are where I should
Caleb look, and there seem to be some defaults in ticker.py:

Caleb class AutoLocator(MaxNLocator): def __init__(self):
Caleb MaxNLocator.__init__(self, nbins=9, steps=[1, 2, 5, 10])

Caleb I don't understand what this means :)

Caleb I would prefer not to hack this directly in the matplotlib
Caleb code.  How can I change the number of ticks on an axis
Caleb programmatically without messing with the other ticklabel
Caleb functionality?

Yes, you will want to use a MaxNLocator.  Note that the MaxNLocator
sets the maximum number of *intervals* so the max number of ticks will
be the max number of intervals plus one.  

  from matplotlib.ticker import MaxNLocator
  from pylab import figure, show, nx

  fig = figure()
  ax = fig.add_subplot(111)
  ax.plot(nx.mlab.rand(1000))
  ax.xaxis.set_major_locator(MaxNLocator(4))
  show()


JDH


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Matplotlib: Histogram with bars inside grid lines...how??

2006-03-29 Thread John Hunter
 Enigma == Enigma Curry [EMAIL PROTECTED] writes:

Enigma I'm playing around with matplotlib for the first time. I'm
Enigma trying to make a very simple histogram of values 1-6 and
Enigma how many times they occur in a sequence. However, after
Enigma about an hour of searching I cannot make the histogram
Enigma stay within the bounds of the grid lines.

Enigma Here is my example:

Enigma pylab.grid() x_values=[1,1,2,2,2,3,3,3,4,4,4,5,5,6,6,6]
Enigma pylab.hist(x_values,6) pylab.show()

Enigma This produced the following image:
Enigma http://enigmacurry.com/usenet/historgram-bars-not-in-grid-lines.png

Enigma Starting with bar number 2, it creeps into grid 1.. and
Enigma finally with bar number 5 it's almost entirely in grid
Enigma 4.. how do I make the bars stay in their own grid lines?

While exactly what you want is something of an enigma to me, I can
offer some advice and terminology.  The bars of hist make no attempt
to stay within the bounds of the grid lines...  The bars have as their
left most boundary the bins you choose for the histogram.  As a first
step, I suggest setting these bins explicitly, rather than letting the
hist command choose them automatically

from pylab import hist, xlim, nx, show

x_values= [1,1,2,2,2,3,3,3,4,4,4,5,5,6,6,6]
bins = nx.arange(0.5, 7.)
hist(x_values, bins)
xlim(0,6.5)
show()

The grid line locations are determined by the xtick locations, which
you can set with the xticks command.

Good luck!
JDH
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Matplotlib: Histogram with bars inside grid lines...how??

2006-03-29 Thread John Hunter
 Enigma == Enigma Curry [EMAIL PROTECTED] writes:

Enigma pylab.xlim(0.5,6.5) should be:

Enigma pylab.xlim(min_x-(bar_width/2),max_x+(bar_width/2))

Glad it's working better for you -- just a couple more smallish hints.

You might prefer to have your grid lines behind, rather than above the
bars.  In that case create the subplot or axes with the axisbelow=True
kwarg.  Despite the fact that you found the kwargs a little annoying
at first, you will probably come to love them.  matplotlib makes very
heavy use of them and they are very useful since they allow matplotlib
to usually do the right things while exposing most of the settings to
you.  Eg

   plot(x, y, 
linewidth=2, linestyle='--', 
marker='o', markerfacecolor='r', markeredgecolor='g'
markeredgewith=2, markersize=10)

and so on.  There are lots of properties you can set on almost every
command.  Because noone wants to type all that, you can use aliases

   plot(x, y, lw=2, ls='--', marker='o', mfc='r', mec='g', mew=2, ms=10)


Secondly, in your example, you are relying implicitly on matplotlib to
pick integer ticks for the xaxis.  It's doing it right in this
example, but might prefer other tick locations for other examples
depending on your x_values.  So set xticks explicitly.

Below is a slightly modified example showing these two ideas.

You also might want to consider joining the mailing list at 

  http://lists.sourceforge.net/mailman/listinfo/matplotlib-users

since you appear to be a little finicky about your figures :-)

def ryan_hist(data, bar_width, min_x, max_x):

Create a frequency histogram over a continuous interval

min_x = the low end of the interval
max_x = the high end of the interval

bar_width = the width of the bars

This will correctly align the bars of the histogram
to the grid lines of the plot

#Make histogram with bars of width .9 and center
#them on the integer values of the x-axis
bins = pylab.nx.arange(1-(bar_width/2),max(data))
pylab.subplot(111, axisbelow=True)
n,bins,patches = pylab.hist(data, bins, width=bar_width)

#Make Y axis integers up to highest n
pylab.yticks(pylab.arange(max(n)))
pylab.xticks(pylab.arange(max(n)+1))
pylab.axis('scaled')
pylab.xlim(min_x-(bar_width/2),max_x+(bar_width/2))
pylab.grid()
pylab.show()


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Computing correlations with SciPy

2006-03-16 Thread John Hunter
 tkpmep == tkpmep  [EMAIL PROTECTED] writes:

tkpmep I want to compute the correlation between two sequences X
tkpmep and Y, and tried using SciPy to do so without success.l
tkpmep Here's what I have, how can I correct it?

 X = [1, 2, 3, 4, 5] Y = [5, 4, 3, 2, 1] import scipy
 scipy.corrcoef(X,Y)
tkpmep Traceback (most recent call last): File interactive
tkpmep input, line 1, in ?  File
tkpmep C:\Python24\Lib\site-packages\numpy\lib\function_base.py,
tkpmep line 671, in corrcoef d = diag(c) File
tkpmep C:\Python24\Lib\site-packages\numpy\lib\twodim_base.py,
tkpmep line 80, in diag raise ValueError, Input must be 1- or
tkpmep 2-d.  ValueError: Input must be 1- or 2-d.


Hmm, this may be a bug in scipy.  matplotlib also defines a corrcoef
function, which you may want to use until this problem gets sorted out

In [9]: matplotlib.mlab.corrcoef(X,Y)

In [10]: X = [1, 2, 3, 4, 5]

In [11]: Y = [5, 4, 3, 2, 1]

In [12]: matplotlib.mlab.corrcoef(X,Y)
Out[12]:
array([[ 1., -1.],
   [-1.,  1.]])


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: FIR filtering

2006-03-15 Thread John Hunter
 LabWINC == LabWINC  [EMAIL PROTECTED] writes:

LabWINC Hi all, i'm looking for a module to implement a digital
LabWINC FIR filter!  Can anyone help me?

scipy.org

Between scipy and matplotlib, you'll feel quite comfortable with
python as a former matlab user

help scipy.filter (see FIR filter design below)

DESCRIPTION
Signal Processing Tools
===

 Convolution:

convolve  --  N-dimensional convolution.
correlate --  N-dimensional correlation.
fftconvolve   --  N-dimensional convolution using the FFT.
convolve2d--  2-dimensional convolution (more options).
correlate2d   --  2-dimensional correlation (more options).
sepfir2d  --  Convolve with a 2-D separable FIR filter.


 B-splines:

bspline   --  B-spline basis function of order n.
gauss_spline  --  Gaussian approximation to the B-spline basis
function.
cspline1d --  Coefficients for 1-D cubic (3rd order)
B-spline.
qspline1d --  Coefficients for 1-D quadratic (2nd order)
B-spline.
cspline2d --  Coefficients for 2-D cubic (3rd order)
B-spline.
qspline2d --  Coefficients for 2-D quadratic (2nd order)
B-spline.

 Filtering:

order_filter  --  N-dimensional order filter.
medfilt   --  N-dimensional median filter.
medfilt2  --  2-dimensional median filter (faster).
wiener--  N-dimensional wiener filter.

symiirorder1  --  2nd-order IIR filter (cascade of first-order
systems).
symiirorder2  --  4th-order IIR filter (cascade of
second-order systems).
lfilter   --  1-dimensional FIR and IIR digital linear
filtering.

deconvolve--  1-d deconvolution using lfilter.

hilbert   --- Compute the analytic signal of a 1-d signal.
get_window--- Create FIR window.

detrend   --- Remove linear and/or constant trends from
data.


 Filter design:

remez --  Optimal FIR filter design.
firwin--- Windowed FIR filter design.
iirdesign --- IIR filter design given bands and gains
iirfilter --- IIR filter design given order and critical
frequencies
freqs --- Analog filter frequency response
freqz --- Digital filter frequency response

Matlab-style IIR filter design:

butter (buttord)  -- Butterworth
cheby1 (cheb1ord) -- Chebyshev Type I
cheby2 (cheb2ord) -- Chebyshev Type II
ellip (ellipord)  -- Elliptic (Cauer)
bessel-- Bessel (no order selection available --
try butterod)

 Linear Systems:

lti -- linear time invariant system object.
lsim -- continuous-time simulation of output to linear system.
impulse -- impulse response of linear, time-invariant (LTI)
system.
step -- step response of continous-time LTI system.

 LTI Reresentations:

tf2zpk -- transfer function to zero-pole-gain.
zpk2tf -- zero-pole-gain to transfer function.
tf2ss -- transfer function to state-space.
ss2tf -- state-pace to transfer function.
zpk2ss -- zero-pole-gain to state-space.
ss2zpk -- state-space to pole-zero-gain.

 Waveforms:

sawtooth -- Periodic sawtooth
square -- Square wave
gausspulse -- Gaussian modulated sinusoid
chirp -- Frequency swept cosine signal

 Wavelets:

daub -- return low-pass filter for daubechies wavelets
qmf  -- return quadrature mirror filter from low-pass
cascade -- compute scaling function and wavelet from
coefficients
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: FIR filtering

2006-03-15 Thread John Hunter
 Terry == Terry Reedy [EMAIL PROTECTED] writes:

Terry LabWINC [EMAIL PROTECTED] wrote in message
Terry news:[EMAIL PROTECTED]
 If i type help scipy.filter it give me an error
 
 help scipy.filter File input, line 1 help scipy.filter ^
 SyntaxError: invalid syntax

Terry The respondant left out parens.  At interactive prompt:
Terry help(scipy.filter) or, in general help(someobject)

Sorry, ipython user here -- http://ipython.scipy.org

ipython supports autoparens

JDH

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Matplotlib logarithmic scatter plot

2006-03-01 Thread John Hunter
 Derek == Derek Basch [EMAIL PROTECTED] writes:

Derek formatter = FuncFormatter(log_10_product)
Derek ax.xaxis.set_major_formatter(formatter)
Derek ax.yaxis.set_major_formatter(formatter)

I would caution you against using identical objects for the x and y
axis *Locators*.  For the formatters, it will do no harm, but for the
locators you can get screwed up because the locator object reads the
axis data and view limits when making it's choices.

Ie, do not do this:

  ax.xaxis.set_major_locator(locator)
  ax.yaxis.set_major_locator(locator)

but rather do this

  ax.xaxis.set_major_locator(MyLocator())
  ax.yaxis.set_major_locator(Mylocator())

Thanks for the example,
JDH
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Matplotlib logarithmic scatter plot

2006-02-28 Thread John Hunter
 Derek == Derek Basch [EMAIL PROTECTED] writes:

Derek Great! That worked fine after I played with it for a
Derek bit. One last question though. How do I label the ticks
Derek with the product of the exponentiation? For instance:

Derek 100

Derek instead of

Derek 10**2

You can supply your own custom tick formatters (and locators).  See

  http://matplotlib.sf.net/matplotlib.ticker.html 

and examples

  http://matplotlib.sourceforge.net/examples/custom_ticker1.py
  http://matplotlib.sourceforge.net/examples/major_minor_demo1.py
  http://matplotlib.sourceforge.net/examples/major_minor_demo2.py

JDH
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Matplotlib logarithmic scatter plot

2006-02-27 Thread John Hunter
 Derek == Derek Basch [EMAIL PROTECTED] writes:

Derek Thanks for the reply. I need a scatter plot though. Can
Derek that be done?

You can set the scale of xaxis and yaxis to either log or linear for
scatter plots

In [33]: ax = subplot(111)

In [34]: ax.scatter( 1e6*rand(1000), rand(1000))
Out[34]: matplotlib.collections.RegularPolyCollection instance at
0x9c32fac

In [35]: ax.set_xscale('log')

In [36]: ax.set_xlim(1e-6,1e6)
Out[36]: (9.9995e-07, 100.0)

In [37]: draw()

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: matplotlib legend problem

2006-01-27 Thread John Hunter
 bwaha == bwaha  [EMAIL PROTECTED] writes:
bwaha added the location argument. Finally realised it was due to
bwaha having a default of 'best' location in my code which meant
bwaha it went searching for intersection with lines that don't
bwaha exist (outside of the LineCollection). So I disabled the
bwaha 'best' location option. Then I figured, since I'd cleaned
bwaha up my code a bit, I'd reinstate my earlier pylab.plot based
bwaha line drawing code to see if the clean up made any
bwaha difference to what was previously abysmal performance. The
bwaha lines plotted faster than the LineCollection code! When I
bwaha removed the legend hack for LineCollections there was
bwaha virtually no difference. (Story is not finshed yet). So I
bwaha figured after all that that I'd reinstate my pylab.plot
bwaha based code since I could plot a greater range of symbols
bwaha than with LineCollections with no speed loss. And I thought
bwaha why not go the whole hog and reinstate the 'best' location
bwaha option too. Boom! Plotting performance was abysmal
bwaha again. Finally I realised that enabling 'best' and having
bwaha it as the default meant that as I added new data to plot,
bwaha the search time for a good place to put the legend
bwaha increased dramtically, and probably became more difficult
bwaha with more and more lines filling the canvas.

bwaha Anyway now I'm a lot happier than when I started because
bwaha I've retained my original range of plot styles and I got
bwaha much faster plotting. Hopefully this lesson can help
bwaha someone else.


Sorry you had to find this out after so much trial and error.  For a
small number of large length lines (eg 10 at 30k points each), plot
will be much faster than line collections as you observed.  For a
large number of small lines (eg 1000 at 20 points each) line
collections will be much faster.  And yes, the best optimization for
the legend is slow -- I'm on the fence as to whether this should be
the default or not.  At least clearly flagging this as a performance
bottleneck in the docs would be useful.

Cheers,
JDH


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: scipy.plt legend?

2005-10-11 Thread John Hunter
 gurkesaft == gurkesaft  [EMAIL PROTECTED] writes:

gurkesaft Thank you, Robert.  I noticed how obsolete it is!
gurkesaft There is no documentation.

gurkesaft Matplotlib freezes my system if I close a plot and make
gurkesaft a new one :(.  Bah.  Windows :)

Have you seen the documentation on 

  http://matplotlib.sf.net/installing.html

In particular, you need to make sure that your backend, shell, and
interactive setting all are harmonious.  One suggestion: in your rc
file, try setting 'backend : TkAgg' and 'interactive : True' in your
http://matplotlib.sf.net/matplotlibrc file.  Also, beware of using
matplotlib from a GUI IDE which uses a different GUI toolkit than the
one you've selected in your rc file.  I realize this is complex -- but
I think it is part and parcel of the curse of python.  python supports
6+ GUI toolkits and so matplotlib does too!  If the GUI mainloop and
matplotlib mainloop don't agree, bad things can happen.

JDH
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Creating Pie Chart from Python

2005-09-16 Thread John Hunter
 Thierry == Thierry Lam [EMAIL PROTECTED] writes:

Thierry Let's say I have the following data: 500 objects: -100
Thierry are red -300 are blue -the rest are green

Thierry Is there some python package which can represen the above
Thierry information in a pie chart?


It looks like in python there is more than one way to make a pie
chart.  Here's another

from pylab import figure, pie, show
N, red, blue = 500, 100, 300
green = N - (red + blue)
figure(figsize=(6,6))
pie( (red, blue, green),
 labels=('red', 'blue', 'green'),
 colors=('red', 'blue', 'green'),)
show()

A screenshot of a slightly more elaborate example is at

http://matplotlib.sourceforge.net/screenshots.html#pie_demo

JDH
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: use SciPy with Python 2.4.1?

2005-08-24 Thread John Hunter
 Robert == Robert Kern [EMAIL PROTECTED] writes:

Robert [EMAIL PROTECTED] wrote:
 Is SciPy usable with Python 2.4.1? At
 http://www.scipy.org/download/ it says that 2.3.3 is
 recommended, and I don't see a binary for 2.4.1.

Robert It is usable with Python 2.4.1 on Linux and OS X at
Robert least. IIRC, mingw-compiled extensions don't work with the
Robert standard Python 2.4.1 interpreter, which is, I believe,
Robert the largest holdup for Windows binaries for 2.4.1.

I routinely compile matplotlib with mingw for 2.4 and haven't had any
problems.  If I recall correctly, a trivial patch for distutils is
needed which is described at
http://mail.python.org/pipermail/python-list/2004-December/254826.html

JDH
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: while c = f.read(1)

2005-08-22 Thread John Hunter
 Robert == Robert Kern [EMAIL PROTECTED] writes:

Robert Greg McIntyre wrote:
 The 2nd option has real potential for me. Although the total
 amount of code is greater, it factors out some complexity away
 from the actual job, so that code is not obscured by
 unnecessary compexity. IMHO that's great practice.

Robert Please quote the message you are replying to. We have no
Robert idea what the 2nd option is.

I think he means the second option you presented

  If you must read one character at a time,

 def reader(fileobj, blocksize=1):
 Return an iterator that reads blocks of a given size from a
 file object until EOF.
 ...snip

With a decent threaded news/mail reader, the thread provides
sufficient context, no?

JDH
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: GUI tookit for science and education

2005-08-17 Thread John Hunter
 James == James Sungjin Kim [EMAIL PROTECTED] writes:

James Michele Simionato wrote:
 My vote is for ipython + matplotlib. Very easy and very
 powerful.

James Is it really easier than to use MATLAB(TM)?

Do you find matlab easy to use?  What aspects are hard or easy?  If
you provide a little more context, it would be easier to answer your
question.

JDH
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: GUI tookit for science and education

2005-08-17 Thread John Hunter
 Robert == Robert Kern [EMAIL PROTECTED] writes:

RobertH = U*D*V.T

Robert then I'm more than happy with that tradeoff. The small
Robert syntactic conveniences MATLAB provides are dwarfed by the
Robert intrinsic power of Python.

Of course, U*D*V (transpose omitted for clarity) is the classic
problem for an interpreted language: the creation of temporaries.
weave allows you, via blitz, to do chained matrix/matrix operations
without multiple passes through the loop and w/o temporaries by
run-time compilation and linking of extension code.  Perhap's the OP's
reference to JIT is referring to a just in time compilation mechanism
in matlab, similar to weave's.  They've already discovered LAPACK and
FFTW; it wouldn't be surprising if they solved blitzm (blitz in
matlab), antialiasing, alpha transparency and multiple colormaps per
figure in upcoming releases.

JDH
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Gotchas in user-space matplotlib install?

2005-08-15 Thread John Hunter
 Matt == Matt Feinstein [EMAIL PROTECTED] writes:

Matt All in all, not actually excruciating-- and now I have a
Matt working version of matplotlib!  Matt Feinstein

Great!  While this is all fresh in your mind, would you be able to add
a wiki entry at
http://www.scipy.org/wikis/topical_software/MatplotlibCookbook

Thanks,
JDH
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Gotchas in user-space matplotlib install?

2005-08-11 Thread John Hunter
 Matt == Matt Feinstein [EMAIL PROTECTED] writes:

Matt Hi all-- I'm planning to try to do a completely local
Matt install of matplotlib (in Fedora Core 1)-- the system
Matt administrator isn't going to stop me-- but he isn't going to
Matt cooperate either. I've got the tarballs for python, numeric,
Matt numarray, matplotlib, ipython, wxpython and freetype-- which
Matt I think covers the various pre-requisites and
Matt post-requisites. One semi-obvious question is where to put
Matt the freetype library (the system version in FC1 is not up to
Matt the required level)-- but I can only wonder what other
Matt trouble I'm going to get into. Any advice before I take the
Matt plunge would be appreciated. TIA...


If you do a --prefix=~/usr for all 'configure' and 'python setup.py
install' commands, and set your PATH, C_INCLUDE_PATH,
CPLUS_INCLUDE_PATH, LIBRARY_PATH, and LD_LIBRARY_PATH variables
accordingly, and set the MATPLOTLIBDATA environment variable to point
to ~/usr/share/matplotlib, it should work.

When debugging your setup, you might want to run your test
matplotlib/pylab script with 

   python myscript.py --verbose-helpful

OR

   python myscript.py --verbose-debug

to get extra information about where matplotlib is looking for things.

JDH


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Passing a variable number of arguments to a wrapped function.

2005-08-05 Thread John Hunter
 stephen == stephen  [EMAIL PROTECTED] writes:

stephen Is there a better way of doing this so that I don't have
stephen to go through every permutation of possible arguments
stephen (the example here from the matplotlib 'plot' function):

You can make linecolor=None and linewidth=None, and then use
matplotlib's rc defaults

  from matplotlib import rcParams
  def makeplot(self, xvalues, yvalues, linecolor=None, linewidth=None):
  if linecolor is None: linecolor = rcParams['lines.color']
  if linewidth is None: linewidth = rcParams['lines.linewidth']
  plot(xvalues, yvalues, color=linecolor, linewidth=linewidth)

Then you can customize the defaults in the rc file
(http://matplotlib.sf.net/matplotlibrc) any way you want.

Alternatively, you can also set the defaults in your script

  from matplotlib import rc
  rc('lines', linewidth=1.0, color='red')

JDH
-- 
http://mail.python.org/mailman/listinfo/python-list


ANN: matplotlib 0.83.2

2005-08-02 Thread John Hunter

matplotlib is a 2D plotting package for python.  This is a summary of
recent developments in matplotlib since 0.80.  For detailed notes, see
http://matplotlib.sf.net/whats_new.html,
http://matplotlib.sf.net/CHANGELOG and
http://matplotlib.sf.net/API_CHANGES

== Whats New ==

matplotlib wiki: this was just launched a few days ago and only has
  two entries to date, but we hope this will grow into a useful site
  with tutorials, howtos, installation notes, recipes, etc.  Please
  contribute!  Thanks to scipy.org and Enthought for hosting.
  http://www.scipy.org/wikis/topical_software/MatplotlibCookbook

CocoaAgg: New CocoaAgg backend for native GUI on OSX, 10.3 and 10.4
  compliant, contributed by Charles Moad.

TeX support : Now you can (optionally) use TeX to handle all of the
  text elements in your figure with the rc param text.usetex in the
  antigrain and postscript backends; see
  http://www.scipy.org/wikis/topical_software/UsingTex.  Thanks to
  Darren Dale for hard work on the TeX support.

Reorganized config files: Made HOME/.matplotlib the new config dir
  where the matplotlibrc file, the ttf.cache, and the tex.cache live.
  Your .matplotlibrc file, if you have one, should be renamed to
  .matplotlib/matplotlibrc.

Masked arrays: Support for masked arrays in line plots, pcolor and
  contours.  Thanks Eric Firing and Jeffrey Whitaker.

New image resize options interpolation options.  See help(imshow) for
  details, particularly the interpolation, filternorm and filterrad
  kwargs.  New values for the interp kwarg are:

'nearest', 'bilinear', 'bicubic', 'spline16', 'spline36',
'hanning', 'hamming', 'hermite', 'kaiser', 'quadric', 'catrom',
'gaussian', 'bessel', 'mitchell', 'sinc', 'lanczos', 'blackman'

Byte images: Much faster imaeg loading for MxNx4 or MxNx3 UInt8
  images, which bypasses the memory and CPU intensive integer/floating
  point conversions.  Thanks Nicolas Girard.

Fast markers on win32: The marker cache optimization is finally
  available for win32, after an agg bug was found and fixed (thanks
  Maxim!).  Line marker plots should be considerably faster now on
  win32.

Qt in ipython/pylab: You can now use qt in ipython pylab mode.  Thanks
  Fernando Perez and the Orsay team!

Agg wrapper proper: Started work on a proper agg wrapper to expose
  more general agg functionality in mpl.  See examples/agg_test.py.
  Lots of wrapping remains to be done.

Subplot configuration: There is a new toolbar button on
  GTK*, WX* and TkAgg to launch the subplot configuration tool.

GUI neutral widgets: Matplotlib now has cross-GUI widgets (buttons,
  check buttons, radio buttons and sliders).  See
  examples/widgets/*.py and
  http://matplotlib.sf.net/screenshots.html#slider_demo.  This makes
  it easier to create interactive figures that run across backends.

Full screen mode in GTK*: Use 'f' to toggle full screen mode in the
  GTK backends.  Thanks Steve Chaplin.

Downloads available from http://matplotlib.sf.net
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


ANN: matplotlib 0.83.2

2005-08-02 Thread John Hunter

matplotlib is a 2D plotting package for python.  This is a summary of
recent developments in matplotlib since 0.80.  For detailed notes, see
http://matplotlib.sf.net/whats_new.html,
http://matplotlib.sf.net/CHANGELOG and
http://matplotlib.sf.net/API_CHANGES

== Whats New ==

matplotlib wiki: this was just launched a few days ago and only has
  two entries to date, but we hope this will grow into a useful site
  with tutorials, howtos, installation notes, recipes, etc.  Please
  contribute!  Thanks to scipy.org and Enthought for hosting.
  http://www.scipy.org/wikis/topical_software/MatplotlibCookbook

CocoaAgg: New CocoaAgg backend for native GUI on OSX, 10.3 and 10.4
  compliant, contributed by Charles Moad.

TeX support : Now you can (optionally) use TeX to handle all of the
  text elements in your figure with the rc param text.usetex in the
  antigrain and postscript backends; see
  http://www.scipy.org/wikis/topical_software/UsingTex.  Thanks to
  Darren Dale for hard work on the TeX support.

Reorganized config files: Made HOME/.matplotlib the new config dir
  where the matplotlibrc file, the ttf.cache, and the tex.cache live.
  Your .matplotlibrc file, if you have one, should be renamed to
  .matplotlib/matplotlibrc.

Masked arrays: Support for masked arrays in line plots, pcolor and
  contours.  Thanks Eric Firing and Jeffrey Whitaker.

New image resize options interpolation options.  See help(imshow) for
  details, particularly the interpolation, filternorm and filterrad
  kwargs.  New values for the interp kwarg are:

'nearest', 'bilinear', 'bicubic', 'spline16', 'spline36',
'hanning', 'hamming', 'hermite', 'kaiser', 'quadric', 'catrom',
'gaussian', 'bessel', 'mitchell', 'sinc', 'lanczos', 'blackman'

Byte images: Much faster imaeg loading for MxNx4 or MxNx3 UInt8
  images, which bypasses the memory and CPU intensive integer/floating
  point conversions.  Thanks Nicolas Girard.

Fast markers on win32: The marker cache optimization is finally
  available for win32, after an agg bug was found and fixed (thanks
  Maxim!).  Line marker plots should be considerably faster now on
  win32.

Qt in ipython/pylab: You can now use qt in ipython pylab mode.  Thanks
  Fernando Perez and the Orsay team!

Agg wrapper proper: Started work on a proper agg wrapper to expose
  more general agg functionality in mpl.  See examples/agg_test.py.
  Lots of wrapping remains to be done.

Subplot configuration: There is a new toolbar button on
  GTK*, WX* and TkAgg to launch the subplot configuration tool.

GUI neutral widgets: Matplotlib now has cross-GUI widgets (buttons,
  check buttons, radio buttons and sliders).  See
  examples/widgets/*.py and
  http://matplotlib.sf.net/screenshots.html#slider_demo.  This makes
  it easier to create interactive figures that run across backends.

Full screen mode in GTK*: Use 'f' to toggle full screen mode in the
  GTK backends.  Thanks Steve Chaplin.

Downloads available from http://matplotlib.sf.net
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is there a better interactive plotter then pylab?

2005-04-27 Thread John Hunter
 Charles == Charles Krug [EMAIL PROTECTED] writes:

Charles List: I'm trying to us pylab to see what I'm doing with
Charles some DSP algorithms, in case my posts about convolution
Charles and ffts weren't giving it away.

Charles I've been using pylab's plot function, but I'm finding it
Charles a bit cumbersome.

Charles It works, but if I switch from the interactive window to
Charles the plot window and back, the plot window gets trashed.

Charles Is there a better alternative for interactive use?

You are probably not using pylab interactive mode properly.
matplotlib has several GUI backends (gtk, tk, qt, etc...).  Most GUIs
take control with their mainloop and prevent further interaction.
From what you describe, I'm pretty sure you haven't setup your
configuration properly for interactive use.  Fortunately, there are a
couple of solutions.

For the standard python shell, you need to use the TkAgg backend.
Tkinter is the only python GUI that plays nicely with the standard
python shell.  You will need to set backend : TkAgg and 
interactive : True in the matplotlib rc file.  See
http://matplotlib.sf.net/interactive.html for details and
http://matplotlib.sf.net/.matplotlibrc for information on the
configuration file.

If you want to use another GUI backend, eg GTKAgg (the default on
linux and also the fastest backend), you need to use a custom python
interpreter which runs the GUI in a thread.  The best choice here is
to use ipython (http://ipython.scipy.org) with the -pylab option.
ipython is aware of matplotlib and its rc file, and will read the rc
file, set the interactive mode, detect the GUI backend, and make the
proper threading calls.  Basically it *just works*.  If you are on
linux, it's an easy install (sudo python setup.py install).  On
windows it's a bit harder, and you may want to look at the 1069
release candidate of enthought python at
http://www.enthought.com/downloads/downloads.htm#download, which comes
with ipython and matplotlib and lots of other goodies.  Again, you'll
need to start ipythhon with

   ipython -pylab

In addition to the links above, see also
http://matplotlib.sf.net/faq.html#SHOW.

Hope this helps,
JDH
-- 
http://mail.python.org/mailman/listinfo/python-list


ANN: matplotlib-0.80

2005-04-14 Thread John Hunter

matplotlib is a 2D graphics package that produces plots from python
scripts, the python shell, or embeds them in your favorite python GUI
-- wx, gtk, tk, fltk and qt.  Unlike many python plotting alternatives
is written in python, so it is easy to extend.  matplotlib is used in
the finance industry, web application servers, and many scientific and
enginneering disciplines.  With a large community of users and
developers, matplotlib is approaching the goal of having a full
featured, high quality, 2D plotting library for python.

A lot of development has gone into matplotlib since the last major
release, which I'll summarize here.  For details, see the notes for
the incremental releases at http://matplotlib.sf.net/whats_new.html. 

Improvements since 0.70

 -- contouring: 

Lots of new contour funcitonality with line and polygon contours
provided by contour and contourf.  Automatic inline contour
labeling with clabel. See
http://matplotlib.sourceforge.net/screenshots.html#pcolor_demo

 -- QT backend
Sigve Tjoraand, Ted Drain and colleagues at the JPL collaborated
on a QTAgg backend

 -- Unicode strings are rendered in the agg and postscript backends.
Currently, all the symbols in the unicode string have to be in the
active font file.  In later releases we'll try and support symbols
from multiple ttf files in one string.  See
examples/unicode_demo.py

 -- map and projections

A new release of the basemap toolkit -  See
http://matplotlib.sourceforge.net/screenshots.html#plotmap

 -- Auto-legends

The automatic placement of legends is now supported with
loc='best'; see examples/legend_auto.py.  We did this at the
matplotlib sprint at pycon -- Thanks John Gill and Phil! Note that
your legend will move if you interact with your data and you force
data under the legend line.  If this is not what you want, use a
designated location code.

 -- Quiver (direction fields)

Ludovic Aubry contributed a patch for the matlab compatible quiver
method.  This makes a direction field with arrows.  See
examples/quiver_demo.py

 -- Performance optimizations

Substantial optimizations in line marker drawing in agg

 -- Robust log plots

Lots of work making log plots just work.  You can toggle log y
Axes with the 'l' command -- nonpositive data are simply ignored
and no longer raise exceptions.  log plots should be a lot faster
and more robust


 -- Many more plotting functions, bugfixes, and features, detailed in
the 0.71, 0.72, 0.73 and 0.74 point release notes at
http://matplotlib.sourceforge.net/whats_new.html


http://matplotlib.sourceforge.net

JDH
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


ANN: matplotlib-0.80

2005-04-14 Thread John Hunter

matplotlib is a 2D graphics package that produces plots from python
scripts, the python shell, or embeds them in your favorite python GUI
-- wx, gtk, tk, fltk and qt.  Unlike many python plotting alternatives
it is written in python, so it is easy to extend.  matplotlib is used
in the finance industry, web application servers, and many scientific
and engineering disciplines.  With a large community of users and
developers, matplotlib is approaching the goal of having a full
featured, high quality, 2D plotting library for python.

A lot of development has gone into matplotlib since the last major
release, which I'll summarize here.  For details, see the incremental
release notes at http://matplotlib.sf.net/whats_new.html.

Improvements since 0.70

 -- contouring: 

Lots of new contour functionality with line and polygon contours
provided by contour and contourf.  Automatic inline contour
labeling with clabel. See
http://matplotlib.sourceforge.net/screenshots.html#pcolor_demo

 -- QT backend
Sigve Tjoraand, Ted Drain and colleagues at the JPL collaborated
on a QTAgg backend

 -- Unicode strings are rendered in the agg and postscript backends.
Currently, all the symbols in the unicode string have to be in the
active font file.  In later releases we'll try and support symbols
from multiple ttf files in one string.  See
examples/unicode_demo.py

 -- map and projections

A new release of the basemap toolkit -  See
http://matplotlib.sourceforge.net/screenshots.html#plotmap

 -- Auto-legends

The automatic placement of legends is now supported with
loc='best'; see examples/legend_auto.py.  We did this at the
matplotlib sprint at pycon -- Thanks John Gill and Phil! Note that
your legend will move if you interact with your data and you force
data under the legend line.  If this is not what you want, use a
designated location code.

 -- Quiver (direction fields)

Ludovic Aubry contributed a patch for the matlab compatible quiver
method.  This makes a direction field with arrows.  See
examples/quiver_demo.py

 -- Performance optimizations

Substantial optimizations in line marker drawing in agg

 -- Robust log plots

Lots of work making log plots just work.  You can toggle log y
Axes with the 'l' keypress -- nonpositive data are simply ignored
and no longer raise exceptions.  log plots should be a lot faster
and more robust

 -- Many more plotting functions, bugfixes, and features, detailed in
the 0.71, 0.72, 0.73 and 0.74 point release notes at
http://matplotlib.sourceforge.net/whats_new.html


Downloads at http://matplotlib.sourceforge.net

JDH
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Gnuplot.py and, _by far_, the weirdest thing I've ever seen on my computer

2005-04-11 Thread John Hunter
 syd == syd  [EMAIL PROTECTED] writes:

syd As for matplotlib, I checked it out.  Looks amazing!  I
syd really, really like what demos I tried.

syd HOWEVER, I could not find a good way to do smoothing.  I like
syd the gnuplot bezier smoothing.  This wouldn't be the hardest
syd thing in the world to code, but I was a little disappointed.
syd If yall have any ideas, bring em on!  :)

What is the gnuplot interface to use smoothing?

When I want to do something like this, I use scipy's interpolate
module and pass the reults to matplotlib for plotting.  


from scipy import arange, sin, pi, interpolate
from pylab import plot, show

t = arange(0, 2.0, 0.1)
y = sin(2*pi*t)
tck = interpolate.splrep(t, y, s=0)
tnew = arange(0, 2.0, 0.01)
ynew = interpolate.splev(tnew, tck, der=0)
plot(t, y, 'o', tnew, ynew)

show()


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Matplotlib question-- Numeric or numarray?

2005-04-08 Thread John Hunter
 Matt == Matt Feinstein [EMAIL PROTECTED] writes:

Matt I'm working my way through the matplotlib documentation 
Matt there's a point that's ambiguous-- the pdf file (dated
Matt Mar. 1, 2005) warns of dire consequences if I use the
Matt 'wrong' array package-- e.g., put numarray in the .matlabrc
Matt file if the compile-time package is Numeric.  But there's
Matt only one current, unlabeled, windows installer and there
Matt seems to have been a change, some time back before version
Matt 0.7, in how this question is dealt with. Can someone
Matt clarify?  thnksndvnc

Hi Matt -- it looks like the documentation is out of data.  matplotlib
can now be built to support Numeric and numarray simultaneously, and
which one you are using is controlled at runtime by the numerix
setting in your rc file.  The windows installers now have support for
both Numeric and numarray built in.

I recommend you use the matplotlib.numerix module to import your
Numeric/numarray symbols in matplotlib scripts, rather than using
Numeric/numarray directly.  The reason is that it is still important
that the arrays you create match the type in your rc file, and the
numerix module insures that this happens.

One good way to do this is

  import matplotlib.numerix as nx
  a = nx.array(blah)


The matplotlib numerix package structure mirros numarray.  Eg to
import mean, you would do

  from matplotlib.numerix.mlab import mean

which in numarray is located in numarray.mlab and in Numeric is in
MLab.

If trying to figure out where all the various numerix functions live
makes your head hurt, you can use the pylab module which aggregates
all the numerix and plotting functions into a single namespace

import pylab as p

a = p.array([1,2,3])
n = p.randn(1)
mu, sigma = p.mean(n), p.std(n)

p.hist(n, 1000)

p.show()


Hope this helps,
JDH



-- 
http://mail.python.org/mailman/listinfo/python-list


using distutils.command.config

2005-03-28 Thread John Hunter

I am trying to utilize the config module in distutils to test for
certain headers and libraries and fail elegantly if they are not found
with a helpful message.  The typical gcc error message when a header
is missing is inscrutable to many.

I have subclassed config and can use my class with 


  python setup.py config

The config class finds all the module specific path and library
information, but I am not clear on the best way to get this to the
build process.  One option is to save the information to a config
file, eg using a plain text format, creating a python module, or using
pickle, but it seems artificial to me to have to use an intermediate
file.  Is there a way to get the config information on a call to 

  python setup.py build

My config class looks like

from distutils.command.config import config

class config_mpl(config):
def run (self):
# make sure you can find the headers, link with the libraries,
# etc, and collect per module include_dirs, library_dirs,
# libraries information

One idea is to dump the information from the config call to a
config.pickle, but ideally I would like the config file to be human
readable

Thanks,
JDH
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: generic text read function

2005-03-17 Thread John Hunter
 les == les ander [EMAIL PROTECTED] writes:

les Hi, matlab has a useful function called textread which I am
les trying to reproduce in python.

les two inputs: filename, format (%s for string, %d for integers,
les etc and arbitary delimiters)

les variable number of outputs (to correspond to the format given
les as input);

les So suppose your file looked like this str1 5 2.12 str1 3 0.11
les etc with tab delimited columns.  then you would call it as

les c1,c2,c3=textread(filename, '%s\t%d\t%f')

les Unfortunately I do not know how to read a line from a file
les using the line format given as above. Any help would be much
les appreciated les

Not an answer to your question, but I use a different approach to
solve this problem.  Here is a simple example

converters = (str, int, float)
results = []
for line in file(filename):
line = line.strip()
if not len(line): continue  # skip blank lines
values = line.split('\t')
if len(values) != len(converters):
raise ValueError('Illegal line')
results.append([func(val) for func, val in zip(converters, values)])

c1, c2, c3 = zip(*results)

If you really need to emulate the matlab command, perhaps this example
will give you an idea about how to get started.  Eg, set up a dict
mapping format strings to converter functions

d = {'%s' : str,
 '%d' : int,
 '%f' : float,
}

and then parse the format string to set up your converters and split function.

If you succeed in implementing this function, please consider sending
it to me as a contribution to matplotlib -- http://matplotlib.sf.net

Cheers,
JDH
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Minor, but annoying legend problem in matplotlib

2005-02-28 Thread John Hunter
 Jorl == Jorl Shefner [EMAIL PROTECTED] writes:

JorlThe obvious solution is to plot the lines and symbols in
Jorl two different commands: ___


You want to explicitly pass the lines you want to legend into the
legend command, as in 

Symb= ['wo','ws','w^']
LineType= ['k-','k--','k-.']

leglines = []
for index,d in enumerate(DataSets):

plot(x,DataSets[index],LineType[index])
lines = plot(x,DataSets[index],Symb[index])
leglines.extend(lines)



legend(leglines, [a,b,c])

Jorl to have it available for the second loop.  I've gotten
Jorl around this before for somewhat similar cases using
Jorl suggestions from this group of explicitly defining the
Jorl values the legend will use:

Jorl L1= plot(x,y,...

Jorl  but I can't figure how to do this here because of the
Jorl looping over the data sets.

Hope the above example helps here.

JorlOn a related note, is there any way to increase the size
Jorl of the markers within the legend?

You can access the lines of the legend instance

leg = legend(lines, labels)
lines = leg.get_lines()
set(lines, markersize=10, markeredgewidth=2)  # etc

See http://matplotlib.sourceforge.net/examples/legend_demo.py

JDH
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: MatPlotLib.MatLab troubles (how to install/run matplotlib.PyLab?)

2005-02-23 Thread John Hunter
 Colombes == Colombes  [EMAIL PROTECTED] writes:

ColombesNow I only need to figure out how to install the
Colombes correct Numeric module(s).  I'm making progress,
Colombes almost have my home laptop fully capable with the
Colombes MatLab-like (PyLab) graphs, plots.

You can get either Numeric or numarray from
http://sourceforge.net/projects/numpy.  matplotlib works transparently
with either (and provides a unified interface to both), but if you
choose numarray you need to change the numerix variable to numarray
in your matplotlib configuration file, which is described at
http://matplotlib.sf.net/.matplotlibrc

Good luck!
JDH

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: MatPlotLib.MatLab troubles (how to install/run matplotlib.PyLab?)

2005-02-21 Thread John Hunter
 Colombes == Colombes  [EMAIL PROTECTED] writes:

Colombes matplotlib.matlab deprecated, please import
Colombes matplotlib.pylab or simply pylab instead.  See
Colombes http://matplotlib.sf.net/matplotlib_to_pylab.py for a
Colombes script which explains this change and will automatically
Colombes convert your python scripts that use matplotlib.matlab.
Colombes This change was made because we were concerned about
Colombes trademark infringement on The Mathwork's trademark of
Colombes matlab.

Colombes Unfortunately, the above URL does not exist.

Oops -- that should be
http://matplotlib.sourceforge.net/matlab_to_pylab.py

In a nutshell, wherever you previously imported matplotlib.matlab you
can import matplotlib.pylab or equivalently, simply pylab

OLD:
from matplotlib.matlab import plot

NEW:
from pylab import plot

The script linked above will recursively search and replace these
strings for you in your scripts directory.

JDH
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Matplotlib, py2exe and pytz

2005-02-19 Thread John Hunter
 scott == scott  [EMAIL PROTECTED] writes:

scott I am trying to convert a python app that uses matplotlib to
scott a standalone executable using py2exe.

scott After running py2exe and executing my app I get the
scott following stack trace:

scott Traceback (most recent call last): File gcToCsv.py, line
scott 5, in ?  File plot_output.pyc, line 1, in ?  File
scott pylab.pyc, line 1, in ?  File matplotlib\pylab.pyc,
scott line 194, in ?  File matplotlib\axes.pyc, line 46, in ?
scott File matplotlib\dates.pyc, line 94, in ?  File
scott pytz\__init__.pyc, line 53, in timezone KeyError: 'UTC'

scott It appears that the instructions on the matplotlib web site
scott and wiki are incomplete and the pytz.zoneinfo package is
scott not being included in the finished dist directory.

In your script that you are trying to freeze, do, 

  import pytz
  import dateutil

as a hint to py2exe that you want these modules.  Does this help?

Does the script you are trying to freeze explicitly use matplotlib
date functionality?

JDH
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Getting milliseconds in Python

2005-02-16 Thread John Hunter
 mjs7231 == mjs7231  [EMAIL PROTECTED] writes:

mjs7231 This is no good, I am looking for milliseconds, not
mjs7231 seconds.. as stated above.

Well seconds/1000.0 = millseconds -- or are you worries about floating
point error?

7  from datetime import datetime
8  dt = datetime.now()
9  dt.microsecond
Out[9]: 20222

Converting to milliseconds is left as an exercise for the reader...

See also the timeit module...


JDH
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Commerical graphing packages?

2005-02-14 Thread John Hunter
 Francis == Francis Girard [EMAIL PROTECTED] writes:

Francis PyX might also be interesting, depending on your needs.

While pyx is a very nice package, it is probably not a good choice for
web app developers simply because it generates postscript, which is
not very browser friendly.  Once could send the PS through a converter
such as ImageMagick, but it would probably be better to use a library
that generates browser friendly output natively.

matplotlib on the other hand, *does* work in web app servers, and
generates PNG/SVG natively.  See
http://matplotlib.sourceforge.net/faq.html#APPSERVER

Although it is a free and open source package, I think that the image
quality and support is on par with if not superior to what you find in
many commercial solutions.  If the OP wants commercial support, he
might consider contacting the developer off-list :-)

JDH
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Variable size plot symbols, variable hue plot colors in Python (MatPlotLib) ?

2005-02-10 Thread John Hunter
 Colombes == Colombes  [EMAIL PROTECTED] writes:

Colombes Using MatPlotLib plot function, is there a way to get
Colombes variable size plot symbols?  For example, using symbol
Colombes strings like 'o' (circle), 's' (square), 'x' (cross),
Colombes etc., is there a way to specify other plot symbols such
Colombes a small circle, Medium square, LARGE cross, etc.?

  plot(x, y, 'o', markersize=10) # big
  plot(x, y, 'o', markersize=20) # bigger

Colombes Similarly, using the MatPlotLib plot function, is there
Colombes a way to get variable hue (RGB-specified) plot colors?
Colombes For example, using symbol strings like 'b' (blue), 'g'
Colombes (green), 'red' (red), etc., is there a way to specify
Colombes other colors such as light blue, dark green, pink, etc.?

All legal html color names are supported

 plot(x, y, 'o', markersize=10, markerfacecolor='green', 
 markeredgecolor='red') 

Eg

lightblue: #ADD8E6  
lightcoral   : #F08080  
lightcyan: #E0  
lightgoldenrodyellow : #FAFAD2  
lightgreen   : #90EE90  
lightgrey: #D3D3D3  
lightpink: #FFB6C1  
lightsalmon  : #FFA07A  
lightseagreen: #20B2AA  
lightskyblue : #87CEFA  
lightslategray   : #778899  
lightsteelblue   : #B0C4DE  
lightyellow  : #E0  


# or use aliases for less typing
 plot(x, y, 'o', ms=10, mfc='green', mec='red') 

# or rgba or hex
 plot(x, y, 'o', ms=10, mfc='#008000, mec=(1,0,0,1) )


Colombes Or perhaps is there some other Python MatPlotLib or
Colombes other Python module functions that allow variable size
Colombes plot symbols and variable hue plot colors in Python ?

The scatter command supports markers with varying sizes and colors.
screenshot with example code at
http://matplotlib.sourceforge.net/screenshots.html#scatter_demo2 .
Docs at
http://matplotlib.sourceforge.net/matplotlib.pylab.html#-scatter.

You might want to check out the tutorial and/or the user's guide.
Most of these issues are touched on there.

JDH
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Medical GUI Application With Python

2005-02-05 Thread John Hunter
 Evrim == Evrim Ozcelik [EMAIL PROTECTED] writes:

Evrim We are developing a medical software about PSG
Evrim (PolySomnoGraphy) analysis. The application takes signal
Evrim data from an electronic device and we will show this
Evrim continious signal function on the interfaces. There are
Evrim about 20-30 signal channels and the user selected channels
Evrim are shown. We want to run this application over different
Evrim platforms.

Evrim My question is:

Evrim1. What must be our IDE 2. What class library for GUI
Evrim must be use (wxWindows, Qt, GTK, etc.)  3. Is there any GUI
Evrim package for visulazing signal functions (like sinozodial
Evrim functions) in real time; this module will behave as an
Evrim oscilloscope

I wrote an EEG viewer in python using pygtk for the GUI and matplotlib
for the 2D plotting (and VTK for the 3D).  It runs unchanged on OSX,
linux and win32.  You can see a few screenshots at
http://pbrain.sf.net .

The underlying 2D plotting library, matplotlib, does handle animations
(dynamic plots) and can be embedded in the GUI of your choice (Tk, WX,
GTK, FLTK and QT).  I also wrote matplotlib, as a first step in
developing the application above.  The performance of dynamic animated
plots (what you call real time) varies for different backends.  GTK is
typically fastest: on a modern P4 you can do about 50 frames/sec for
simple plots and 10-15 frames/sec for more complicated plots (images,
larger data sets).  The performance for the Tk GUI is considerably
slower.

Most people who say real time don't really mean it, they mean they
want frequent updates and should assess whether the plotting library
can support refresh rates (frames/sec) that are fast enough to be
visually pleasing and to be true to the signal plotted.  matplotlib is
not the fastest 2D python plotting library, but it is one of the most
feature complete and may be fast enough for your purposes --
http://matplotlib.sf.net .  My guess is that for 20-30 channels the
refresh rate in the current implementation will be slower than you
want, but these things are always improving since matplotlib is under
active development and there are some performance bottlenecks that
could be removed with a little work.

The examples directory which is in the src distributions has a number
of examples illustrating dynamic plots: anim.py, system_monitor.py,
dynamic_image_gtkagg.py, dynamic_image_wxagg.py, dynamic_demo.py.

JDH
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: exporting mesh from image data

2005-02-04 Thread John Hunter
 Fernando == Fernando Perez [EMAIL PROTECTED] writes:

Fernando I hope you posted this on the VTK list with a CC to
Fernando Prabhu as well...  The hopes of a positive reply there
Fernando are, I suspect, a fair bit higher.  The scipy list would
Fernando be a good idea, too.

Hey Fernando, 

I did get some help from Prabu off list.  The suggestion was to use a
vtkDelaunay3D to mesh the isosurface points into a volume, which
returns an unstructured grid, and then iterate over this structure to
get the volume, face, vertex and connectivity information out.  I've
implemented this and we're in the process of testing it with some
simple geometries.  If/when I get something tested and working, I'll
post it.

Thanks for the links,
JDH
-- 
http://mail.python.org/mailman/listinfo/python-list


exporting mesh from image data

2005-02-03 Thread John Hunter

I am trying to generate a mesh for a finite volume solver (gambit,
fluent) from 3D image data (CT, MRI).  To generate the fluent msh
file, you need not only a list of vertices and polygons, much like
what is available in the vtk file format, but also the volume elements
in the mesh that the polygons abut.  Eg for a given triangle in the
mesh, you would have a line like

  3 3 2 1 11 0

which is 

  numfaces vert0 vert1 vert2 vol1 vol2

where vol1 and vol2 are indices that indicate the volume in the mesh
that the triangle belongs to (vol2 is 0 for triangles on the surface).

The specific problem at hand involves building a mesh for ventricles
in the brain.  I have no trouble building the isosurface that
surrounds the ventricles using the marching cubes and connectivity
filters in VTK, but now need to be able to generate a mesh over the
interior and assign volumes to faces.

Does such capability exist in VTK? and if so I would be thankful for
pointers to class docs or examples.  Are there other algorithms in the
world of python 3D libraries that can provide 3D meshes for 2D surface
isocontours, assigning volume elements from the mesh to the surfaces
that surround the volume.

Thanks!
JDH


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: barchart for webpage needed

2005-01-31 Thread John Hunter
 dimitri == dimitri pater [EMAIL PROTECTED] writes:

dimitri Hello, I am looking for a Python tool to create graphs
dimitri and charts on a webpage. Chartdirector is too expensive
dimitri for me. A simple script for creating a barchart should be
dimitri sufficient as a starting point.

matplotlib does barcharts, errorbars, stacked bars, and more (and its
free).  See the following links

# matplotlib with web app servers: 
http://matplotlib.sourceforge.net/faq.html#APPSERVER

# a barchart screenshot with example code
http://matplotlib.sourceforge.net/screenshots.html#barchart_demo


# the bar command for making bar charts
http://matplotlib.sourceforge.net/matplotlib.pylab.html#-bar

JDH
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python's idiom for function overloads

2005-01-31 Thread John Hunter
 Frans == Frans Englich [EMAIL PROTECTED] writes:

Frans Hello,

Frans Since Python doesn't have static typing, how is the same
Frans result as traditional function overloads results in
Frans acheived? With function overloads the selection of code
Frans path depending on data type is transparent and automatic
Frans since the typing system figure out what goes to what.

Frans But in Python, when one wants to be able to pass different
Frans data types into a single entry point for functionality,
Frans how is that best done? To in a function do an if statement
Frans with the type() function?

Using type or isinstance is one way to do it.  The other way is duck
typing.  If it walks like a duck and talks like a duck, it probably
is a duck.  The core idea is that we care less about what type an
object is, and more about what services the object provides.  Eg

def myoverload(x):

  try: noise = x.quack()
  except AttributeError: # do something else...
  else: # do something with noise

Variants to the try/except approach include hasattr, getattr and so
on..

googling python duck typing should speed you on your way.

JDH

-- 
http://mail.python.org/mailman/listinfo/python-list


python and gpl

2005-01-30 Thread John Hunter

I have a question about what it takes to trigger GPL restrictions in
python code which conditionally uses a GPL library.

Here is the context of my question.  matplotlib, which I develop, is a
plotting module which is distributed under a PSF compatible license,
and hence we avoid using GPLd code so as to not trigger the GPL
requirements.  matplotlib has rigid segregation between the front end
(plotting commands, figure objects, etc) and backends (gtk, wx, ps,
svg, etc).  The backend is chosen dynamically at runtime -- eg the
same python script could trigger the import gtk, wx, or ps, depending
an some rc settings or command line opts.

The question is: does shipping a backend which imports a module that
links with GPL code make some or all of the library GPL.  This
question is complicated, in my mind at least, by several factors.

Here are some sub-questions:

  * If a backend module somebackend does

 import somelib

where somelib is a python wrapper of GPL code, is somebackend
GPLd?

  * Assuming the answer to the above question is yes, is matplotlib
GPLd if it distributes somebackend?  I think this is a nuanced
situation because matplotlib would work just fine w/o somemodule,
and only uses somemodule's code if it is selected at runtime by
the user.  Ie, no other part of the code depends on it since it is
one of many interchangeable backends.

  * To further complicate the question, the backend in question is qt,
which is dual licensed, commercial and GPL.  The qt backend code
just needs to 'import qt', and neither the backend writer nor the
matplotlib frontend knows whether the deployed qt on the system is
commercial or GPLd.  To date, the only GPL-like backend is GTK,
which is LGPL.  Since we're only linking and not using the src,
we're protected from the GPL requirements.  With QT, which has a
pure (non L) GPL variant, the situation is less clear to me.

Thoughts, links, etc, appreciated...


JDH
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Installing Numeric with ATLAS and LAPACK

2005-01-28 Thread John Hunter
 drife == drife  [EMAIL PROTECTED] writes:

drife Hello, Could someone please provide instructions for
drife install Numeric with ATLAS and LAPACK?

Locate libcblas.a and add that dir to the setup.py library_dirs_list.
Eg on my system, /usr/local/lib/ATLAS/lib/Linux_P4SSE2_2/libcblas.a

setup.py:

library_dirs_list = ['/usr/local/lib/ATLAS/lib/Linux_P4SSE2_2']

Do the same for cblas.h and add it to the include_dirs var in
setup.py, on my system it is /usr/local/lib/ATLAS/include/cblas.h, so
in setup.py

include_dirs = ['/usr/local/lib/ATLAS/include/', '/usr/include/atlas']

Then python setup.py install *should* work.

JDH
-- 
http://mail.python.org/mailman/listinfo/python-list


handling xls with pyuno

2005-01-28 Thread John Hunter

Does anyone have any example scripts using the OpenOffince
python-bridge module pyuno to load xls, extract the data, and/or save
to another format such as xsc or csv.

Thanks,
JDH
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Installing Numeric with ATLAS and LAPACK

2005-01-28 Thread John Hunter
 drife == drife  [EMAIL PROTECTED] writes:

drife Thanks John. Those are the steps I followed, and to no
drife avail.  

Make sure you get a clean build by rm -rf ing the build dir before you
build again.  Then capture the output of your build to a file.  When
you say to no avail what do you mean -- that the calculation was
slower.  If you still have troubles, post again to the
numpy-discussion list listing what you did and the output of the build
process.

Good luck!
JDH
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: LinearAlgebra incredibly slow for eigenvalue problems

2005-01-28 Thread John Hunter
 drife == drife  [EMAIL PROTECTED] writes:

drife Hi David, I performed the above check, and sure enough,
drife Numeric is --not-- linked to the ATLAS libraries.

drife I followed each of your steps outlined above, and Numeric
drife still is not linking to the ATLAS libraries.

drife My setup.py file is attached below.

Are you sure that you 

 1) 'rm -rf build'   before rebuilding

 2) are using the python / Numeric that you think you are, eg, might
you have one python in /usr/bin and another in /usr/local.  root
paths can differ from user paths which may effect which python is
used at install time versus run time

-- 
http://mail.python.org/mailman/listinfo/python-list


detect tk mainloop

2005-01-26 Thread John Hunter

In matplotlib using the tkagg backend, the tk mainloop is started at
the end of a python script by issuing a call to a show function,
which realizes all the created figure windows and the calls
Tkinter.mainloop().  This can cause problems if the mainloop was
started by another module (eg idle).

Is there a way to query tkinter to detect whether the mainloop has
already been called?

Thanks,
JDH
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python without OO

2005-01-26 Thread John Hunter
 Davor == Davor  [EMAIL PROTECTED] writes:

Davor not really - it was not my intention at all - but it seems
Davor people get upset whenever this OO stuff is mentioned - and
Davor what I did not expect at all at this forum as I believed
Davor Python people should not be so OO hardcore (seems not all
Davor as quite a few have indicated in their
Davor replies)... Nevertheless, I think the discussion has
Davor several quite good points!  --
Davor http://mail.python.org/mailman/listinfo/python-list

Consider the case of a list, say 

x = [1,2,3,4]

suppose you wanted to reverse the list, so that x becomes [4,3,2,1].
In a procedural language, one might do

  x = reverse(x)

In an OO language such as python, one might do

  x.reverse()

Is the OO way more obscure and complicated, etc?  Not really -- it's
only a minor syntactical difference.  One of the core ideas behind OO
programming is that data (the contents of the list 1,2,3,4) and
methods (sorting, reversing) are bound together into a single entity,
the object.  On the face of it, this is rather sensible.

You may rightly recoil against unnecessary abstraction and complexity,
abuse of multiple inheritance and so on.  That's perfectly sensible.
But object orientation is probably not the bogey man here.  python
values readable code that is as simple as possible (but no simpler!)
as you seem to.  Focus on the actual problem, which is probably not OO
programming, but colleagues who are making a design more complex than
need be.

Indeed, the third chant in the mantra of python is Simple is better
than complex.

John-Hunters-Computer:~ python
Python 2.3 (#1, Sep 13 2003, 00:49:11) 
[GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin
Type help, copyright, credits or license for more information.
 import this
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python without OO

2005-01-26 Thread John Hunter
 beliavsky == beliavsky  [EMAIL PROTECTED] writes:

beliavsky I think the OO way is slightly more obscure. It's
beliavsky obvious what x = reverse(x) does, but it is not clear
beliavsky unless you have the source code whether x.reverse()

You don't need to read the src, you just need to read the docs

   help([].reverse)
  Help on built-in function reverse:

  reverse(...)
  L.reverse() -- reverse *IN PLACE*

beliavsky reverses x or if it returns a reversed list. If
beliavsky x.reverse() does the former, a disadvantage relative to
beliavsky the procedural approach is that a function can be used
beliavsky in an expression. It is clearer and more concise to
beliavsky write

beliavsky z = reverse(x) + reverse(y)

The distinction is not OO versus procedural, it is a decision about
how you choose to write reverse.  The python list implementers of
the reverse object method could have decided to return a new reversed
list rather than do the reverse in place and return None.  Then you
could have done

  z = x.reverse() + y.reverse()

They could have chosen to reverse the list *in place* and also
returned a reference to self rather than None, in which case you could
do the above as well.  w/o digging up the transcripts from the
python-dev mailing list, my guess is that they choose to do it in
place for efficiency in memory and cpu, and chose not to return self
to prevent user confusion.  Ie, if a user was allowed to do 'z =
x.reverse() + y.reverse()' they might be surprised to find the side
effect of in place modification.

Likewise, I could easily write a procedural in place reverse that
returns None, in which case 'z = reverse(x) + reverse(y)' would not do
what you suggest.  My point is that whether a function/method such as
reverse operates in place or on a copy, and whether it returns None or
a reference to a list is independent of OO vs procedural style and is
motivated by considerations of efficiency, readability, and usability.

beliavsky Furthermore, if in Python the algorithm for the reverse
beliavsky function applies to many kinds of objects, it just
beliavsky needs to be coded once, whereas a reverse method would
beliavsky have to provided for each class that uses it (perhaps
beliavsky through inheritance).

True, a generic reverse procedure/function can be applied to any data
structure that supports iteration.  In the case of python, however,
some iterable data structures are mutable (lists, dicts) and some are
not (strings, tuples).  For mutable sequences, an in place reverse is
likely to be more efficient in memory and perhaps CPU than a generic
reverse which returns a new copy.  So a specialized method reverse
applicable to lists (but not strings and tuples) can be a big win.
Fortunately, python supports both, allowing you to define a general
reverse that works for any object that supports the sequence
protocol, as well as to define an object specific reverse method that
may be faster in time and space.   

JDH

-- 
http://mail.python.org/mailman/listinfo/python-list


ANN: matplotlib-0.71

2005-01-25 Thread John Hunter

matplotlib is a 2D graphics package that produces plots from python
scripts, the python shell, or embeds them in your favorite python GUI
-- wx, gtk, tk, fltk currently supported with qt in the works. Unlike
many python plotting alternatives is written in python, so it is
easy to extend. matplotlib is used in the finance industry, web
application servers, and many scientific and enginneering disciplines.
With a large community of users and developers, matplotlib is
approaching the goal of having a full featured, high quality, 2D
plotting library for python.

  http://matplotlib.sourceforge.net

What's new in matplotlib 0.71

numerix refactor

  The organization of the numerix module was refactored to be mindful
  of namespaces. See http://matplotlib.sf.net/API_CHANGES. pylab no
  longer overrides the built-ins min, max, and sum, and provides amin,
  amax and asum as the numerix/mlab versions of these.  pylab defines
  __all__ to prevent surprises when doing from pylab import *.  To see
  the complete list of symbols provided

 import matplotlib.pylab
 matplotlib.pylab.__all__

contour zigzag bug fixed

  Thanks Nadia for the blood, sweat and tears, and Dominique for the
  report.

contour colormaps

  Contour now uses the current colormap if colors is not provided, and
  works with colorbars.  See examples/contour_demo2.py

colorbar enhancements

  Horizontal colorbars supported with keyword arg
  orientation='horizontal' and colorbars can be placed in an arbitrary
  axes with keyword arg cax.

accents in mathtext

  Added accents to mathtext: \hat, reve, \grave, ar, cute, ilde, ec,
  \dot, \ddot. All of them have the same syntax, eg to make an overbar
  you do ar{o} or to make an o umlaut you do \ddot{o}. The shortcuts
  are also provided, eg: o 'e \`e \~n \.x \^y . See
  examples/accent_demo.py

fixed super/subscript parsing in mathtext

  Widowed superscripts now work, eg r'$^12 m{CO}$'

little bugs and enhancements

  Plugged some memory leaks in wx and image module, fixed x,y args in
  contour, added latex symbol kappa, fixed a yticklabel problem under
  change in clim, fixed colorbar number of color bug, fixed
  set_clip_on bug, reverted pythoninspect in tkagg, fixed event
  handling bugs, fixed matlab-compatible load function, exposed vbox
  attr in FigureManagerGTK.


Downloads at http://matplotlib.sourceforge.net

JDH
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to write a tutorial

2005-01-21 Thread John Hunter
 Xah == Xah Lee [EMAIL PROTECTED] writes:

Xah at places often a whole paragraph on some so called computer
Xah science jargons should be deleted. They are there more to
Xah showcase inane technicality than do help the
Xah reader. (related, many passages with jargons should be
Xah rewritten sans inane jargon. e.g. mutable object.)

The concept of mutable objects is extremely important in python, and
understanding is the key to answering two recurring newbie questions

  * Why can't lists or dictionaries be keys to dictionaries?

  * Why does using a list as a default value for a keyword argument in
a function definition often lead to unexpected results?

So it is definitely appropriate material in a tutorial.  

As for jargon, it is hard to argue that object is inane jargon in
python.  In fact, the base class for new-styled classes is indeed
object, and if you want to write one of these classes yourself, you
need to do 'class MyClass(object)'.  So object is not inane jargon in
an object oriented programming language.  You still with me?

OK, now on to mutable.  mutable means changeable, albeit it's a little
more of an obscure word than changeable, but it does roll off the
tongue a bit more easily.  Perhaps 'changeable object' would be more
accessible to some readers, but it doesn't flow as well.  So the
python tutorial should perhaps define mutable when it introduces it.
Which it does somewhat implicitly; the first time mutable is mentioned in the
docs, in the context of strings

  Unlike strings, which are immutable, it is possible to change
  individual elements of a list:


And now for my last musing on a new topic How to write a critique:
It is much more constructive to suggest new text for documentation
than to brand it inane.

JDH
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Graph and Table implementation

2005-01-21 Thread John Hunter
 Jan == Jan Rienyer Gadil [EMAIL PROTECTED] writes:

Jan could anyone please help me!  what and how is the best
Jan implementation of creating a table based on data coming from
Jan the serial port ? and also how would i be able to create
Jan graphs (2D) based on these data?

Jan opinions and suggestion are most highly welcome. thanks.

matplotlib can handle most kinds of 2D plots -- it even has a table
command for including simple tabular data in your graph

  http://matplotlib.sourceforge.net/screenshots.html#table_demo

so for heavy duty tables you'll probably want to use a GUI widget.

JDH
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: problem with import pylab from a website

2005-01-20 Thread John Hunter
 jean == jean rossier [EMAIL PROTECTED] writes:

jean Hello All, I am facing a problem while importing pylab
jean library(in a .py program file) via web browser however the
jean same program works when I execute it from the command
jean prompt.

jean Error message we get:


   Permission denied: '/usr/share/matplotlib/.ttffont.cache', referer:

One solution is to give yourself write permission to
/usr/share/matplotlib.  If this is not possible or in unpalatable for
sysadmin reasons, you have a couple of options.

matplotlib creates a font cache .ttffont.cache of the ttf files it
finds on your system.  If the HOME environment variable is set, it
places the cache file in the HOME dir.  So if setting HOME is a viable
option for you, simply set this to a writable directory on your system
and you are good to go.  This is the approach I recommend.

If HOME does not exist, matplotlib falls back on its data path: this
is where fonts, icons and other goodies live.  You can also customize
this directory by setting the MATPLOTLIBDATA environment variable.  If
you go this route, more all the files currently in
/usr/share/matplotlib to some other directory, say /my/dir, and make
sure it is writable, and then set MATPLOTLIBDATA to point to it.

Note matplotlib has a configuration file that controls all of the
default settings for the plot.  If you want to edit these, the edited
file can also be placed in the HOME directory.  See
http://matplotlib.sf.net/.matplotlibrc .

Hope this helps,
JDH
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Unbinding multiple variables

2005-01-20 Thread John Hunter
 Johnny == Johnny Lin [EMAIL PROTECTED] writes:

Johnny Hi!  Is there a way to automate the unbinding of multiple
Johnny variables?  Say I have a list of the names of all
Johnny variables in the current scope via dir().  Is there a
Johnny command using del or something like that that will iterate
Johnny the list and unbind each of the variables?


Hi Johnny 

I assume you are the one and only Johnny Lin at the U of C, no?

John-Hunters-Computer:~ python
Python 2.3 (#1, Sep 13 2003, 00:49:11) 
[GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin
Type help, copyright, credits or license for more information.
 x = 1
 y = 2
 locals()
{'__builtins__': module '__builtin__' (built-in), '__name__':
'__main__', 'y': 2, '__doc__': None, 'x': 1}
 print x,y   
1 2
 del locals()['x']
 print x,y
Traceback (most recent call last):
  File stdin, line 1, in ?
NameError: name 'x' is not defined
 locals()
{'__builtins__': module '__builtin__' (built-in), '__name__':
'__main__', 'y': 2, '__doc__': None}
 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: problems with duplicating and slicing an array

2005-01-20 Thread John Hunter
 Yun == Yun Mao [EMAIL PROTECTED] writes:
Yun 2. Is there a way to do Matlab style slicing? e.g. if I have
Yun i = array([0, 2]) x = array([1.1, 2.2, 3.3, 4.4]) I wish y =
Yun x(i) would give me [1.1, 3.3] Now I'm using map, but it gets
Yun a little annoying when there are two dimensions.  Any ideas
Yun would be deeply appreciated!

numarray supports matlab style indexing if you pass the ind as an
array or list of indices (but not a tuple, I found to my surprise).
As pointed out already, for Numeric you need to use the take function

 from numarray import array
 x = array([1,2,3,4,5,6,7,8,9])
 ind = [3,5,7]
 inda = array(ind) 
 indt = tuple(ind)
 x[ind]
array([4, 6, 8])
 x[inda]
array([4, 6, 8])
 x[indt]
Traceback (most recent call last):
  File stdin, line 1, in ?
IndexError: too many indices.

I'm sure the tuple surprise is a documented feature.

JDH
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [OT] Good C++ book for a Python programmer

2005-01-19 Thread John Hunter
 Philippe == Philippe C Martin [EMAIL PROTECTED] writes:

Philippe I suggest you google 'C++ tutorial' Regards,

Stroustup's The C++ Programming Language is the best C++ book I've
read.  It is at a fairly high level, and I already had read several
C++ books before reading it, so it may be tough sledding.  But I would
try this first since you are an experienced programmer and know OO
concepts, and if it fails to satisfy try something lighter.
Unfortunately, I didn't like any of the other kinder, gentler overview
books I read on C++, so can't really recommend anything along those
lines, though I'm sure they are out there.

JDH
-- 
http://mail.python.org/mailman/listinfo/python-list


ANN: matplotlib-0.70

2004-12-31 Thread John Hunter

matplotlib is a 2D graphics package that produces plots from python
scripts, the python shell, or embeds them in your favorite python GUI
-- wx, gtk, tk, fltk currently supported with qt in the works.  Unlike
many python plotting alternatives is written in python, so it is
easy to extend.  matplotlib is used in the finance industry, web
application servers, and many scientific and enginneering disciplines.
With a large community of users and developers, matplotlib is
approaching the goal of having a full featured, high quality, 2D
plotting library for python.

A lot of development has gone into matplotlib since the last major
release, which I'll summarize here.  For details, see the notes for
the incremental releases at http://matplotlib.sf.net/whats_new.html.

Major changes since matplotlib-0.60

 - The alpha version of the users guide -
   http://matplotlib.sf.net/users_guide.pdf.  There are still a number
   of sections to be completed, but it's a start!

 - The matlab namespace renamed pylab - if you are upgrading from a
   version older than 0.64, please remove site-packages/matplotlib
   before upgrading.  See
   http://matplotlib.sourceforge.net/matlab_to_pylab.py 

 - New plot types: contour plots (contour), polar charts (polar),
   horizontal bar charts (barh), pie charts (pie), sparse matrix
   visualization (spy and spy2).  Eg,
   http://matplotlib.sf.net/screenshots.html#polar_demo

 - Full ipython http://ipython.scipy.org integration in the pylab
   mode for interactive control of matplotlib plots from the python
   shell.

 - A significantly improved interactive toolbar for panning, zooming,
   zoom to rect - see
   http://matplotlib.sf.net/tutorial.html#toolbar2. 

 - New backends: FLTK, Cairo, GTKCairo

 - Text - rotated mathtext, mathtext for postscript, text bounding
   boxes

 - Colormaps - 14 colormaps built-in
   http://matplotlib.sf.net/screenshots.html#pcolor_demo

 - Images - performance optimizations for 4x faster large image
   handling, PIL support, interpolation and colorbar improvements,
   imread

 - Event handling for capturing mouse clicks, movements, keypresses,
   etc. - same pylab interface works across GUIs.  See
   examples/keypress_demo.py, examples/picker_demo.py,
   examples/coords_demo.py

 - set and get matlab style property introspection -
   http://matplotlib.sf.net/examples/set_and_get.py

 - improved dates handling for dates and date string formatting from
   -, eg
   http://matplotlib.sf.net/screenshots.html#finance_work

 - Be sure to check out the 120 examples at
   http://matplotlib.sf.net/examples


  Home page   : http://matplotlib.sourceforge.net
  Downloads   : http://sourceforge.net/projects/matplotlib 
  Screenshots : http://matplotlib.sourceforge.net/screenshots.html
  Tutorial: http://matplotlib.sourceforge.net/tutorial.html
  Credits : http://matplotlib.sourceforge.net/credits.html

John Hunter
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Using Python in my programs

2004-12-29 Thread John Hunter
 Squirrel == Squirrel Havoc [EMAIL PROTECTED] (takeout) (takeout) 
 writes:

Squirrel Hello. I am sorry if this has been asked before, but I
Squirrel am new here.

Welcome

Squirrel If I recall correctly, Python can be used as a scripting
Squirrel language for other programs, as if the program had a
Squirrel builtin Python interpreter.  I wish to extend my
Squirrel programs by making them scriptable with Python scripts.

Squirrel Is this possible? If so, does anyone know where I can
Squirrel find documentation on it? I searched the python.org site
Squirrel and didnt find anything useful

Google embedding python.  First link is a good place to start --
http://docs.python.org/ext/ext.html -- the official docs for extending
and embedding python.  Extending python is when you want to write or
wrap some library, typically C, C++ or FORTRAN, and expose its
functionality to python.  Embedding python is when you want to use the
python interpreter in your own program.  Start with the official docs
mentioned above, and then check out SWIG and boost::python.

JDH
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Legend problems in MatPlotLib

2004-12-16 Thread John Hunter
 Jorl == Jorl Shefner [EMAIL PROTECTED] writes:

JorlI've only been able to plot data with both symbols and
Jorl lines by issuing two plot commands, one for markers and one
Jorl for lines.  That's perfectly fine, but it creates a problem
Jorl when I try to create a legend for it.  For some reason, the
Jorl legend command by default alternates between using symbols
Jorl and lines, grabbing displaying the symbol from the first
Jorl plot command for the first series, then displaying a line
Jorl type from the second plot for the next series, etc.  This
Jorl behavior is a bit strange, and in fact unacceptable when the
Jorl same line type is used for each series.

Example code always helps, but note you can plot a line with lines and
markers like this

  plot(x, y, '--s')  # dashed line with square markers.

In this case matplotlib will recognize this as one line and should do
the legending properly.  

However, if you do, which I infer you are from your post

  plot(x, y, 's')  # square markers.
  plot(x, y, '--s')  # square markers.

the plot will look the same but matplotlib considers this to be two
different lines and the legend will be messed up.

Note you can explicitly control what gets added to the legend, eg with

  l1, l2 = plot(x, y, '--s', x1, y1, 'go')  
  p = bar(x3,y2)
  legend((l1, p), ('My lines', 'My bars'))

In other words, if you don't like the way the autolegend is setup, you
can explicitly control the process.

Hope this helps.

JDH

-- 
http://mail.python.org/mailman/listinfo/python-list


building extension modules under 2.4 / cygwin

2004-12-13 Thread John Hunter

For the first time, I am trying to compile a matplotlib installer for
win32 / python2.4 under cygwin.  I tested this earlier with one of the
pre-release candidates and had no troubles.  But when I compile with
python2.4, I get the following error when I try and import my
extension code

  the procedure entry point _ctype could not be located in the dynamic
  link libary msvcr71.dll

This DLL resides in C:\Windows\System32 on my system

If I edit the distutils/cygwincompiler.py file and remove the line
that add this lib


elif msc_ver == '1310':
# MSVC 7.1
#self.dll_libraries = ['msvcr71']
self.dll_libraries = []

My code compiles, links and runs fine, at least in initial tests

Any reason I shouldn't be doing this?

JDH

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Looking for a coder to do some work

2004-12-13 Thread John Hunter
 Cameron == Cameron Laird [EMAIL PROTECTED] writes:

Cameron I don't understand the last sentence; in particular,
Cameron fort hsi is beyond my power to decode unambiguously.

for this, clearly wink

JDH
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 3.0

2004-12-12 Thread John Hunter
 duane == duane osterloth [EMAIL PROTECTED] writes:

duane I'm looking for a stand alone email program which is not
duane browser based.  I simply want to write, send and receive
duane email without accessing the internet.  Is Python 3.0 that
duane kind of program?  I'd appreciate your response.

Hi Duane,

I'm a little confused by your request to send and receive email
without accessing the internet, since email generally travels over the
internet.  Do you only want to handle email over an internal network?
Or did you mean that you wanted to do this without accessing an
internet browser such as Internet Explorer?  I'm guessing the latter.

In any case, python has a full complement of internet ready modules to
send and receive email, so it will serve your purposes well.  Go to
http://groups.google.com and search for

  python email

and read through some of the responses.  Consider also reading the
book Foundations of Python Network Programming, and take a look at
the documentation for some of the modules related to email handling in
the internet protocols sections of the python standard library
reference at http://www.python.org/doc/current/lib/internet.html.

Note that python 2.3.4 is the latest official release.  python 3.0
does not exist, though some people have spoken of python 3.0 and
python 3000 generically in terms of a future python release that will
include certain language constructs not available today.

JDH
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Ideas for projects

2004-12-10 Thread John Hunter
 Phillip == Phillip Bowden [EMAIL PROTECTED] writes:

Phillip I feel that I've learned the language pretty well, but
Phillip I'm having trouble thinking of a medium to large project
Phillip to start.  

Some of these may be on the large side, but

 - Provide a full-feature, mostly specification complete python pdf
   parser.

 - Write a proper python package manager that recursively handles
   dependencies across platforms (CPAN/apt-get for python).

 - Enhance GUI integration.  Ie, allow python code targetting one GUI
   environment to be used in a different one (contribute to anygui?)
 
 - Add 3D graphics to matplotlib (nudge, nudge, my own project).
   Integrate VTK?

 - Contribute a full-featured wavelets analysis package for python 

 - Add internationalization support to your favorite python package
   which lacks it.

 - Add client side python support to mozilla and/or XUL

 - Write a python app that crawls python-list USENET posts looking for
   book or GUI-toolkit recommendations and automatically responds with
   links to FAQs and google groups.  Be sure to include google is
   your friend in every response.

 - Contribute to the ipython rewrite effort so that python finally has
   an interactive shell across platforms worth its salt that has a
   chance of being included in the standard library.

 - Solve the problems with the global interpreter lock and give python
   a proper security model that will satisfy everyone with a hardcore
   Java and C++ background.  Implement a proper Rational class and
   support date string formatting over the range of dates that the
   datetime module supports.  Provide a full featured timezone module
   for the standard library.  Support compile time type identification
   for runtime optimizations.

If any or all of these have already been done, my apologies to the
respective authors.

JDH
 


-- 
http://mail.python.org/mailman/listinfo/python-list