Re: [matplotlib-devel] plotting a series of 3D points and, picker=True and 3D

2008-01-29 Thread Neil Crighton
I think it would be a shame to lose the current matplotlib 3d plotting
functionality, even if it's not ideal.  I've found it very useful for
plotting small sets of data, and much more straightforward to use than
Mayavi or other vtk-based 3d plotting packages.

Having said that, I'm not volunteering to make the 3d modules work
with the new transforms :-/

Neil

>
> Message: 2
> Date: Tue, 29 Jan 2008 15:07:31 -0500
> From: Michael Droettboom <[EMAIL PROTECTED]>
> Subject: Re:
> To: Johann Cohen-Tanugi <[EMAIL PROTECTED]>,  matplotlib
> development list 
> Message-ID: <[EMAIL PROTECTED]>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> Johann Cohen-Tanugi wrote:
> > is basemap deferred as well? It is kinda 3D no?
>
> I understand basemap is working reasonably well.  But Jeff Whitaker
> would know better than I.
>
> > Second a color map or
> > contour plot is kinda 2D either.. unless I am confusing what you
> > mean by 2D : 2D in rendering or in data structure?
>
> I mean 2D in rendering -- matplotlib is fundamentally built on top of 2D
> rendering APIs, which makes doing a lot of 3D things more
> computationally expensive and less flexible than a dedicated 3D plotting
> package.
>
> > Anyway, I am probably not the motivated individual to tackle this work,
> > most of all because I do not know matplotlib internals, I am just a
> > user, albeit with coding abilities.
>
> Well, anyone can jump in ;)  Unfortunately, I probably don't have the
> time for that now.  I believe John Hunter has some more fully-formed
> ideas about where 3D in matplotlib should go and where the best path may
> be going forward.
>
> Cheers,
> Mike
>
> > Michael Droettboom wrote:
> >> Yes, it is probably a good-sized chunk of work.  In the recent
> >> transforms overhaul, the 3d stuff was deferred, so it hasn't been
> >> updated to use the new "way of doing things".
> >>
> >> Just "getting it to work as it did before" is probably less work than
> >> "rethinking what 3D means in the context of matplotlib", which is a
> >> fundamentally 2D plotting environment.  And there was some thinking
> >> along the lines of "why bother with the former, if the latter may be
> >> on the horizon?..."  But I think it's going to take some motivated
> >> individual to step up and do either of these.
> >>
> >> Cheers,
> >> Mike
> >>

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] axis limits bug with twinx?

2008-01-29 Thread Michael Droettboom
For some reason, when axis() is called, the "emit" flag (which 
determines whether to update all of the shared axes) was being set to 
False by default.  There may be a good reason for this that I'm not 
aware of, but it seems reasonably harmless, and doesn't break the 
existing shared_axis examples.  I've fixed this on the branch and the 
trunk, but I'm happy to revert if anyone says "stop, bad idea!!!"

Cheers,
Mike

Jörgen Stenarson wrote:
> Hi,
> 
> I have problem setting the axis limits when using a twinx plot. I assume 
> it should be possible to set both x-axis limits after a pylab.twinx() 
> call by issuing only one call to pylab.axis.
> 
> The attached tries to plot the same figure in two different ways the 
> first way ends up with different x axis limits for the two plots. The 
> second shows my workaround.
> 
> /Jörgen
> 
> 
> 
> 
> 
> -
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
> 
> 
> 
> 
> ___
> Matplotlib-devel mailing list
> Matplotlib-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


[matplotlib-devel] axis limits bug with twinx?

2008-01-29 Thread Jörgen Stenarson

Hi,

I have problem setting the axis limits when using a twinx plot. I assume 
it should be possible to set both x-axis limits after a pylab.twinx() 
call by issuing only one call to pylab.axis.


The attached tries to plot the same figure in two different ways the 
first way ends up with different x axis limits for the two plots. The 
second shows my workaround.


/Jörgen


import sys,os,pdb
import numpy
import pylab
from numpy import sin,cos,pi

x=numpy.arange(0,2*pi,0.1)
x=numpy.arange(0,18,0.1)

pylab.figure(1)
pylab.subplot(111)
pylab.plot(x,sin(x)*0.01)
pylab.axis(xmax=20,ymin=-0.02,ymax=0.02)
pylab.twinx()
pylab.plot(x,cos(x)*0.01)
pylab.axis(xmax=20,ymin=-0.02,ymax=0.02)

pylab.figure(2)
ax1=pylab.subplot(111)
pylab.plot(x,sin(x)*0.01)
pylab.axis(ymin=-0.02,ymax=0.02)
ax2=pylab.twinx()
pylab.plot(x,cos(x)*0.01)
ax2.set_xlim(xmax=20)
ax2.set_ylim(ymin=-0.02,ymax=0.02)
-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


[matplotlib-devel] marker in a plot crashes pdf backend

2008-01-29 Thread Jörgen Stenarson

Hi,

I think there is a bug in the pdf backend (png-files save ok) that makes 
plots crash when they contain a marker.


The attached script crashes on the last savefig. I have also attached a 
traceback.


I run matplotlib-svn-4904 on windows with python 2.4

/Jörgen

Traceback (most recent call last):
  File "loglog_bug.py", line 13, in ?
pylab.savefig("slask2.pdf")
  File 
"c:\python\external\matplotlib\build\lib.win32-2.4\matplotlib\pyplot.py", line 
271, in savefig
return fig.savefig(*args, **kwargs)
  File 
"c:\python\external\matplotlib\build\lib.win32-2.4\matplotlib\figure.py", line 
854, in savefig
self.canvas.print_figure(*args, **kwargs)
  File 
"c:\python\external\matplotlib\build\lib.win32-2.4\matplotlib\backend_bases.py",
 line 1084, in print_figure
orientation=orientation,
  File 
"c:\python\external\matplotlib\build\lib.win32-2.4\matplotlib\backend_bases.py",
 line 994, in print_pdf
return pdf.print_pdf(*args, **kwargs)
  File 
"c:\python\external\matplotlib\build\lib.win32-2.4\matplotlib\backends\backend_pdf.py",
 line 1865, in print_pdf
file.close()
  File 
"c:\python\external\matplotlib\build\lib.win32-2.4\matplotlib\backends\backend_pdf.py",
 line 438, in close
self.writeMarkers()
  File 
"c:\python\external\matplotlib\build\lib.win32-2.4\matplotlib\backends\backend_pdf.py",
 line 1081, in writeMarkers
self.writePath(path, trans)
  File 
"c:\python\external\matplotlib\build\lib.win32-2.4\matplotlib\backends\backend_pdf.py",
 line 1114, in writePath
cmds = self.pathOperations(path, transform)
  File 
"c:\python\external\matplotlib\build\lib.win32-2.4\matplotlib\backends\backend_pdf.py",
 line 1093, in pathOperations
for points, code in tpath.iter_segments():
  File "c:\python\external\matplotlib\build\lib.win32-2.4\matplotlib\path.py", 
line 201, in iter_segments
num_vertices = NUM_VERTICES[code]
TypeError: list indices must be integers
import pylab,matplotlib
from numpy import array,arange,pi,sin,cos

x=arange(0,2*pi,0.1)

pylab.figure(1)
pylab.clf()
pylab.plot(x,sin(x),"r-")
pylab.savefig("slask1.png")
pylab.savefig("slask1.pdf")
pylab.plot(x, cos(x),"bx")
pylab.savefig("slask2.png")
pylab.savefig("slask2.pdf")

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] [Matplotlib-users] plotting a series of 3D points and, picker=True and 3D

2008-01-29 Thread Michael Droettboom
Yes, it is probably a good-sized chunk of work.  In the recent 
transforms overhaul, the 3d stuff was deferred, so it hasn't been 
updated to use the new "way of doing things".

Just "getting it to work as it did before" is probably less work than 
"rethinking what 3D means in the context of matplotlib", which is a 
fundamentally 2D plotting environment.  And there was some thinking 
along the lines of "why bother with the former, if the latter may be on 
the horizon?..."  But I think it's going to take some motivated 
individual to step up and do either of these.

Cheers,
Mike

Johann Cohen-Tanugi wrote:
> is there a lot of work involved in getting it in? I can wait a bit, or 
> even try to help out It is not critical as I know plenty other way 
> to get the plot I want Just that  I love matplotlib and scipy
> 
> best,
> Johann
> 
> Michael Droettboom wrote:
>> The axes3d stuff is not currently working on the SVN trunk.  You 
>> probably want to use 0.91.2 or the v0_91_maint branch in SVN instead.
>>
>> Cheers,
>> Mike
>>
>> Johann Cohen-Tanugi wrote:
>>> hello,
>>> thanks for answering. I actually fail with the import :
>>> In [1]: from matplotlib import axes3d
>>> --- 
>>>
>>> ImportError   Traceback (most recent call 
>>> last)
>>>
>>> /home/cohen/bstw/ in ()
>>>
>>> /usr/lib/python2.5/site-packages/matplotlib/axes3d.py in ()
>>>  14 from axes import Axes
>>>  15 import cbook
>>> ---> 16 from transforms import unit_bbox
>>>  17
>>>  18 import numpy as npy
>>>
>>> ImportError: cannot import name unit_bbox
>>>
>>> any idea?
>>>
 --

 Message: 1
 Date: Sun, 27 Jan 2008 22:18:00 +
 From: "Neil Crighton" <[EMAIL PROTECTED]>
 Subject: Re: [Matplotlib-users] plotting a series of 3D points and
 picker=True and 3D
 To: [EMAIL PROTECTED]
 Message-ID:
 <[EMAIL PROTECTED]>
 Content-Type: text/plain; charset=ISO-8859-1

 I think scatter3D does what you want:

 from matplotlib import axes3d
 import pylab as pl
 fig = pl.figure()
 ax = axes3d.Axes3D(fig)
 ax.scatter3D(data[:,0],data[:,1],data[:,2])
 ax.set_xlabel('X value')
 ax.set_ylabel('Y value')
 ax.set_zlabel('Z value')
 pl.show()

 You could also change the colour and size of each point based on other
 array values:

 col = ax.scatter3D(data[:,0], data[:,1], data[:,2], c=data[:,3],
 cmap=pl.cm.jet, s=data[:,4])
 cbar = fig.colorbar(col,shrink=0.9,extend='both')
 cbar.ax.set_ylabel('axis 3 data values')

 Pretty nifty.

 Neil

  
>>>
>>> - 
>>>
>>> This SF.net email is sponsored by: Microsoft
>>> Defy all challenges. Microsoft(R) Visual Studio 2008.
>>> http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
>>> ___
>>> Matplotlib-users mailing list
>>> [EMAIL PROTECTED]
>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>

-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] marker in a plot crashes pdf backend

2008-01-29 Thread Michael Droettboom
Interesting.  I can't reproduce this with Python-2.5 on Linux.  What 
version of numpy do you have installed?  Can you send your matplotlibrc 
file?

Cheers,
Mike

Jörgen Stenarson wrote:
> Hi,
> 
> I think there is a bug in the pdf backend (png-files save ok) that makes 
> plots crash when they contain a marker.
> 
> The attached script crashes on the last savefig. I have also attached a 
> traceback.
> 
> I run matplotlib-svn-4904 on windows with python 2.4
> 
> /Jörgen
> 
> 
> 
> 
> -
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
> 
> 
> 
> 
> ___
> Matplotlib-devel mailing list
> Matplotlib-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] [Matplotlib-users] plotting a series of 3D points and, picker=True and 3D

2008-01-29 Thread Michael Droettboom
Johann Cohen-Tanugi wrote:
> is basemap deferred as well? It is kinda 3D no?

I understand basemap is working reasonably well.  But Jeff Whitaker 
would know better than I.

> Second a color map or 
> contour plot is kinda 2D either.. unless I am confusing what you 
> mean by 2D : 2D in rendering or in data structure?

I mean 2D in rendering -- matplotlib is fundamentally built on top of 2D 
rendering APIs, which makes doing a lot of 3D things more 
computationally expensive and less flexible than a dedicated 3D plotting 
package.

> Anyway, I am probably not the motivated individual to tackle this work, 
> most of all because I do not know matplotlib internals, I am just a 
> user, albeit with coding abilities.

Well, anyone can jump in ;)  Unfortunately, I probably don't have the 
time for that now.  I believe John Hunter has some more fully-formed 
ideas about where 3D in matplotlib should go and where the best path may 
be going forward.

Cheers,
Mike

> Michael Droettboom wrote:
>> Yes, it is probably a good-sized chunk of work.  In the recent 
>> transforms overhaul, the 3d stuff was deferred, so it hasn't been 
>> updated to use the new "way of doing things".
>>
>> Just "getting it to work as it did before" is probably less work than 
>> "rethinking what 3D means in the context of matplotlib", which is a 
>> fundamentally 2D plotting environment.  And there was some thinking 
>> along the lines of "why bother with the former, if the latter may be 
>> on the horizon?..."  But I think it's going to take some motivated 
>> individual to step up and do either of these.
>>
>> Cheers,
>> Mike
>>
>> Johann Cohen-Tanugi wrote:
>>> is there a lot of work involved in getting it in? I can wait a bit, 
>>> or even try to help out It is not critical as I know plenty other 
>>> way to get the plot I want Just that  I love matplotlib and scipy
>>>
>>> best,
>>> Johann
>>>
>>> Michael Droettboom wrote:
 The axes3d stuff is not currently working on the SVN trunk.  You 
 probably want to use 0.91.2 or the v0_91_maint branch in SVN instead.

 Cheers,
 Mike

 Johann Cohen-Tanugi wrote:
> hello,
> thanks for answering. I actually fail with the import :
> In [1]: from matplotlib import axes3d
> ---
>  
>
> ImportError   Traceback (most recent 
> call last)
>
> /home/cohen/bstw/ in ()
>
> /usr/lib/python2.5/site-packages/matplotlib/axes3d.py in ()
>  14 from axes import Axes
>  15 import cbook
> ---> 16 from transforms import unit_bbox
>  17
>  18 import numpy as npy
>
> ImportError: cannot import name unit_bbox
>
> any idea?
>
>> -- 
>>
>>
>> Message: 1
>> Date: Sun, 27 Jan 2008 22:18:00 +
>> From: "Neil Crighton" <[EMAIL PROTECTED]>
>> Subject: Re: [Matplotlib-users] plotting a series of 3D points and
>> picker=True and 3D
>> To: [EMAIL PROTECTED]
>> Message-ID:
>> <[EMAIL PROTECTED]>
>> Content-Type: text/plain; charset=ISO-8859-1
>>
>> I think scatter3D does what you want:
>>
>> from matplotlib import axes3d
>> import pylab as pl
>> fig = pl.figure()
>> ax = axes3d.Axes3D(fig)
>> ax.scatter3D(data[:,0],data[:,1],data[:,2])
>> ax.set_xlabel('X value')
>> ax.set_ylabel('Y value')
>> ax.set_zlabel('Z value')
>> pl.show()
>>
>> You could also change the colour and size of each point based on 
>> other
>> array values:
>>
>> col = ax.scatter3D(data[:,0], data[:,1], data[:,2], c=data[:,3],
>> cmap=pl.cm.jet, s=data[:,4])
>> cbar = fig.colorbar(col,shrink=0.9,extend='both')
>> cbar.ax.set_ylabel('axis 3 data values')
>>
>> Pretty nifty.
>>
>> Neil
>>
>>  
>
> - 
>
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
> ___
> Matplotlib-users mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users

>>

-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] marker in a plot crashes pdf backend

2008-01-29 Thread Jörgen Stenarson

Michael Droettboom skrev:
Interesting.  I can't reproduce this with Python-2.5 on Linux.  What 
version of numpy do you have installed?  Can you send your matplotlibrc 
file?




I tried upgrading numpy to the latest svn version but I still see the 
same problem. My matplotlibrc file is just the default created at 
buildtime, I have attached it.


/Jörgen



### MATPLOTLIBRC FORMAT

# This is a sample matplotlib configuration file.  It should be placed
# in HOME/.matplotlib/matplotlibrc (unix/linux like systems) and
# C:\Documents and Settings\yourname\.matplotlib (win32 systems)
#
# By default, the installer will overwrite the existing file in the
# install path, so if you want to preserve your's, please move it to
# your HOME dir and set the environment variable if necessary.
#
# This file is best viewed in a editor which supports python mode
# syntax highlighting
#
# Blank lines, or lines starting with a comment symbol, are ignored,
# as are trailing comments.  Other lines must have the format
#
#   key : val   # optional comment
#
# Colors: for the color values below, you can either use
#  - a matplotlib color string, such as r, k, or b
#  - an rgb tuple, such as (1.0, 0.5, 0.0)
#  - a hex string, such as ff00ff  (no '#' symbol)
#  - a scalar grayscale intensity such as 0.75
#  - a legal html color name, eg red, blue, darkslategray

 CONFIGURATION BEGINS HERE
# the default backend; one of GTK GTKAgg GTKCairo FltkAgg QtAgg TkAgg
# WX WXAgg Agg Cairo GD GDK Paint PS PDF SVG Template
backend  : TkAgg
numerix  : numpy  # numpy, Numeric or numarray
#maskedarray : False   # True to use external maskedarray module
   # instead of numpy.ma; this is a temporary
   # setting for testing maskedarray.
#interactive  : False  # see 
http://matplotlib.sourceforge.net/interactive.html
#toolbar  : toolbar2   # None | classic | toolbar2
#timezone : UTC# a pytz timezone string, eg US/Central or 
Europe/Paris

# Where your matplotlib data lives if you installed to a non-default
# location.  This is where the matplotlib fonts, bitmaps, etc reside
#datapath : /home/jdhunter/mpldata


### LINES
# See http://matplotlib.sourceforge.net/matplotlib.lines.html for more
# information on line properties.
#lines.linewidth   : 1.0 # line width in points
#lines.linestyle   : -   # solid line
#lines.color   : blue
#lines.marker  : None# the default marker
#lines.markeredgewidth  : 0.5 # the line width around the marker symbol
#lines.markersize  : 6# markersize, in points
#lines.dash_joinstyle : miter# miter|round|bevel
#lines.dash_capstyle : butt  # butt|round|projecting
#lines.solid_joinstyle : miter   # miter|round|bevel
#lines.solid_capstyle : projecting   # butt|round|projecting
#lines.antialiased : True # render lines in antialised (no jaggies)

### PATCHES
# Patches are graphical objects that fill 2D space, like polygons or
# circles.  See
# http://matplotlib.sourceforge.net/matplotlib.patches.html for more
# information on patch properties
#patch.linewidth: 1.0 # edge width in points
#patch.facecolor: blue
#patch.edgecolor: black
#patch.antialiased  : True# render patches in antialised (no jaggies)

### FONT
#
# font properties used by text.Text.  See
# http://matplotlib.sourceforge.net/matplotlib.font_manager.html for more
# information on font properties.  The 6 font properties used for font
# matching are given below with their default values.
#
# The font.family property has five values: 'serif' (e.g. Times),
# 'sans-serif' (e.g. Helvetica), 'cursive' (e.g. Zapf-Chancery),
# 'fantasy' (e.g. Western), and 'monospace' (e.g. Courier).  Each of
# these font families has a default list of font names in decreasing
# order of priority associated with them.
#
# The font.style property has three values: normal (or roman), italic
# or oblique.  The oblique style will be used for italic, if it is not
# present.
#
# The font.variant property has two values: normal or small-caps.  For
# TrueType fonts, which are scalable fonts, small-caps is equivalent
# to using a font size of 'smaller', or about 83% of the current font
# size.
#
# The font.weight property has effectively 13 values: normal, bold,
# bolder, lighter, 100, 200, 300, ..., 900.  Normal is the same as
# 400, and bold is 700.  bolder and lighter are relative values with
# respect to the current weight.
#
# The font.stretch property has 11 values: ultra-condensed,
# extra-condensed, condensed, semi-condensed, normal, semi-expanded,
# expanded, extra-expanded, ultra-expanded, wider, and narrower.  This
# property is not currently implemented.
#
# The font.size property is the default font size for text, given in pts.
# 12pt is the standard value.
#
#font.family : sans-serif
#font.style  : normal
#font.variant: normal
#font.weight : medium
#font.stretch: norm

Re: [matplotlib-devel] marker in a plot crashes pdf backend

2008-01-29 Thread Michael Droettboom
Ok, to save me the trouble of installing Python-2.4 (which doesn't feel 
like the culprit, but appears to be the only variable other than 
platform) I seem to recall a discussion on numpy about coercion of 
scalars to Python int's that may be the culprit here.  Can you please 
add the following line above the line where the exception is raised in 
path.py, line 201, and then send me the output:

print code, type(code), codes, type(codes)

Also, does changing:

num_vertices = NUM_VERTICES[code]

to

num_vertices = NUM_VERTICES[int(code)]

resolve the problem?

Cheers,
Mike

Jörgen Stenarson wrote:
> Michael Droettboom skrev:
>> Interesting.  I can't reproduce this with Python-2.5 on Linux.  What 
>> version of numpy do you have installed?  Can you send your 
>> matplotlibrc file?
>>
> 
> I tried upgrading numpy to the latest svn version but I still see the 
> same problem. My matplotlibrc file is just the default created at 
> buildtime, I have attached it.
> 
> /Jörgen
> 
> 
> 

-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] marker in a plot crashes pdf backend

2008-01-29 Thread Michael Droettboom
Ok.  I'll change this in SVN.

Nils Wagner wrote:
> On Tue, 29 Jan 2008 15:33:46 -0500
>  Michael Droettboom <[EMAIL PROTECTED]> wrote:
>> Ok, to save me the trouble of installing Python-2.4 (which doesn't 
>> feel like the culprit, but appears to be the only variable other than 
>> platform) I seem to recall a discussion on numpy about coercion of 
>> scalars to Python int's that may be the culprit here. Can you please 
>> add the following line above the line where the exception is raised in 
>> path.py, line 201, and then send me the output:
>>
>>print code, type(code), codes, type(codes)
>>
> 
> 1  [1 2 1 2] 
> 2  [1 2 1 2] 
> 1  [1 2 1 2] 
> 2  [1 2 1 2] 
> 
>> Also, does changing:
>>
>>num_vertices = NUM_VERTICES[code]
>>
>> to
>>
>>num_vertices = NUM_VERTICES[int(code)]
>>
>> resolve the problem?
> 
> Yes.
> 
> Cheers,
> Nils
>  

-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] ginput: blocking call for mouse input

2008-01-29 Thread Gael Varoquaux
Ooops, I had forgotten to add the Wx backend. Here is a new patch.

By the way, with the wx backend, there seems to be a simple mistake in
the "show" method of the figure manager, to reproduce the traceback do
(with a recent ipython):

ipython -wthread -pylab
In [1]: f = figure()

In [2]: f.show()

Cheers,

Gaël

On Wed, Jan 30, 2008 at 03:05:13AM +0100, Gael Varoquaux wrote:
> Hi all,

> A while ago (a year or so), I was looking for a ginput-like function with
> matplotlib. For those who don't know what I am talking about, it is a
> blocking call that can be used in a script to ask the user to enter
> coordinnate by clicking on the figure. This is incredibly handy, as it
> allows some simple user interaction without worrying about events loop
> and Co.

> At the time I gave up on that. I have made progress with GUI and event
> loops, and a recent post on the matplotlib-user list put me back to work
> on this (
> http://www.nabble.com/ginput-is-here%21-%28for-wx-anyway%29-to14960506.html
> ).

> I have a preliminary patch to add this feature to matplotlib that I
> attach. I add a method to the backend canvases, to be able to deal with
> event-loop-handling, and following Jack Gurkesaft I create my own a small
> event-loop to poll for events inside my function. This is a kludge, but it
> allows to block the function while still processing events. If you have
> better ideas.

> I have implemented the functionnality for all the interactive backends I
> could test (and thus not cocoa), but I am not too sure my gtk code is
> kosher, I wouldn't mind advice on this one.

> The code of ginput itself is currently in a seperate file
> (matplotlib.ginput, that you can run for a demo) because I wasn't too
> sure where to add it.

> This is a first version of the patch. I would like comments on it,
> especially where to add the code itself, and if the proposed additions to
> the backends look all right.

> Once I have comments, I plan to:

> * Make right click cancel an input
> * Allow infinite number of inputs, terminated by right-click
> * Add optional display of inputs
> * Rework docstrings

> More suggestions welcomed,

> This could (and should, IMHO) open the road to other blocking calls for
> user interaction, like the selection of a window, as they make life
> really easy for people wanting to hack quick data analysis scripts.

> Cheers,

> Gaël

> Index: trunk/matplotlib/lib/matplotlib/backend_bases.py
> ===
> --- trunk/matplotlib/lib/matplotlib/backend_bases.py  (revision 4908)
> +++ trunk/matplotlib/lib/matplotlib/backend_bases.py  (working copy)
> @@ -1151,7 +1151,13 @@
>  """
>  return self.callbacks.disconnect(cid)

> +def flush_events(self):
> +""" Flush the GUI events for the figure. Implemented only for
> +backends with GUIs.
> +"""
> +raise NotImplementedError

> +
>  class FigureManagerBase:
>  """
>  Helper class for matlab mode, wraps everything up into a neat bundle
> Index: trunk/matplotlib/lib/matplotlib/ginput.py
> ===
> --- trunk/matplotlib/lib/matplotlib/ginput.py (revision 0)
> +++ trunk/matplotlib/lib/matplotlib/ginput.py (revision 0)
> @@ -0,0 +1,80 @@
> +
> +from matplotlib.pyplot import gcf
> +import time
> +
> +class BlockingMouseInput(object):
> +""" Class that creates a callable object to retrieve mouse click 
> +in a blocking way, a la MatLab. 
> +"""
> +
> +callback = None 
> +verbose = False
> +
> +def on_click(self, event):
> +""" Event handler that will be passed to the current figure to
> +retrieve clicks.
> +"""
> +# if it's a valid click, append the coordinates to the list
> +if event.inaxes:
> +self.clicks.append((event.xdata, event.ydata))
> +if self.verbose: 
> +print "input %i: %f,%f" % (len(self.clicks), 
> +event.xdata, event.ydata)
> +
> +def __call__(self, fig, n=1, timeout=30, verbose=False):
> +""" Blocking call to retrieve n coordinate pairs through mouse 
> +clicks.
> +"""
> +
> +assert isinstance(n, int), "Requires an integer argument"
> +
> +# Ensure that the current figure is shown 
> +fig.show()
> +# connect the click events to the on_click function call
> +self.callback = fig.canvas.mpl_connect('button_press_event', 
> +self.on_click)
> +
> +# initialize the list of click coordinates
> +self.clicks = []
> +
> +self.verbose = verbose
> +
> +# wait for n clicks
> +counter = 0
> +while len(self.clicks) < n:
> +fig.canvas.flush_events()
> +# rest for a moment
> +time.sleep(0.01)
> +
> +# check for a time

[matplotlib-devel] ginput: blocking call for mouse input

2008-01-29 Thread Gael Varoquaux
Hi all,

A while ago (a year or so), I was looking for a ginput-like function with
matplotlib. For those who don't know what I am talking about, it is a
blocking call that can be used in a script to ask the user to enter
coordinnate by clicking on the figure. This is incredibly handy, as it
allows some simple user interaction without worrying about events loop
and Co.

At the time I gave up on that. I have made progress with GUI and event
loops, and a recent post on the matplotlib-user list put me back to work
on this (
http://www.nabble.com/ginput-is-here%21-%28for-wx-anyway%29-to14960506.html
).

I have a preliminary patch to add this feature to matplotlib that I
attach. I add a method to the backend canvases, to be able to deal with
event-loop-handling, and following Jack Gurkesaft I create my own a small
event-loop to poll for events inside my function. This is a kludge, but it
allows to block the function while still processing events. If you have
better ideas.

I have implemented the functionnality for all the interactive backends I
could test (and thus not cocoa), but I am not too sure my gtk code is
kosher, I wouldn't mind advice on this one.

The code of ginput itself is currently in a seperate file
(matplotlib.ginput, that you can run for a demo) because I wasn't too
sure where to add it.

This is a first version of the patch. I would like comments on it,
especially where to add the code itself, and if the proposed additions to
the backends look all right.

Once I have comments, I plan to:

* Make right click cancel an input
* Allow infinite number of inputs, terminated by right-click
* Add optional display of inputs
* Rework docstrings

More suggestions welcomed,

This could (and should, IMHO) open the road to other blocking calls for
user interaction, like the selection of a window, as they make life
really easy for people wanting to hack quick data analysis scripts.

Cheers,

Gaël
Index: trunk/matplotlib/lib/matplotlib/backend_bases.py
===
--- trunk/matplotlib/lib/matplotlib/backend_bases.py(revision 4908)
+++ trunk/matplotlib/lib/matplotlib/backend_bases.py(working copy)
@@ -1151,7 +1151,13 @@
 """
 return self.callbacks.disconnect(cid)
 
+def flush_events(self):
+""" Flush the GUI events for the figure. Implemented only for
+backends with GUIs.
+"""
+raise NotImplementedError
 
+
 class FigureManagerBase:
 """
 Helper class for matlab mode, wraps everything up into a neat bundle
Index: trunk/matplotlib/lib/matplotlib/ginput.py
===
--- trunk/matplotlib/lib/matplotlib/ginput.py   (revision 0)
+++ trunk/matplotlib/lib/matplotlib/ginput.py   (revision 0)
@@ -0,0 +1,80 @@
+
+from matplotlib.pyplot import gcf
+import time
+
+class BlockingMouseInput(object):
+""" Class that creates a callable object to retrieve mouse click 
+in a blocking way, a la MatLab. 
+"""
+
+callback = None 
+verbose = False
+
+def on_click(self, event):
+""" Event handler that will be passed to the current figure to
+retrieve clicks.
+"""
+# if it's a valid click, append the coordinates to the list
+if event.inaxes:
+self.clicks.append((event.xdata, event.ydata))
+if self.verbose: 
+print "input %i: %f,%f" % (len(self.clicks), 
+event.xdata, event.ydata)
+
+def __call__(self, fig, n=1, timeout=30, verbose=False):
+""" Blocking call to retrieve n coordinate pairs through mouse 
+clicks.
+"""
+
+assert isinstance(n, int), "Requires an integer argument"
+
+# Ensure that the current figure is shown 
+fig.show()
+# connect the click events to the on_click function call
+self.callback = fig.canvas.mpl_connect('button_press_event', 
+self.on_click)
+
+# initialize the list of click coordinates
+self.clicks = []
+
+self.verbose = verbose
+
+# wait for n clicks
+counter = 0
+while len(self.clicks) < n:
+fig.canvas.flush_events()
+# rest for a moment
+time.sleep(0.01)
+
+# check for a timeout
+counter += 1
+if timeout > 0 and counter > timeout/0.01: 
+print "ginput timeout"; 
+break;
+
+# All done! Disconnect the event and return what we have
+fig.canvas.mpl_disconnect(self.callback)
+self.callback = None
+return self.clicks
+
+
+def ginput(n=1, timeout=30, verbose=False):
+"""
+Blocking call to interact with the figure. 
+
+This will wait for n clicks from the user and return a list of the 
+coordinates of each click.
+
+If timeout is negative, does not tim