[Matplotlib-users] find the projected distance between two curves

2009-02-19 Thread G. Allegri
Hello list,
I'm completely new to matplotlib and I'm not a computer scientist (not
a good starting point!) but I need to solve a geometric/graphical
problem.
I've been asked to find a method, in Python, to find the distance
between a 2D polynomial curve, derived from least squares
interpolation on a set of points, and a curve locallly interpolating
another set of points.

 - the starting line is a smooth line, while the second should
describe a path passing exactly thorugh the given points.
 - the distance should be the one along the normal to the first line

I attach a sketch to explain this.

Is there an heuristic, an algorithm, to solve this problem in an
efficient way (I have to apply it to thousands couples of sets from
sonar and seismic acquisitions)? Is the mapltolip API useful for this?

Thanks in advance,
Giovanni
attachment: linesnormalsketch.png--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Polar bars and matplotlib 0.98.5

2009-02-19 Thread Laurent Mychkine
hi,

I'm using polar bars to plot windroses. Since the 0.98.5 version i have
some issues with the plots.
The 0° bar is not displayed in the good way. This bar is
located between -0.26 radian and 0.26 radian but it is printed
counterclockwise.
It was working perfectly with matplotlib version 0.98.3. I just switched to
version 0.98.5 because of the NaN bug of the previous version.

Any idea how i could make it work again ?
Ty!!

from pylab import *
nb_secteur=12

fig = figure(2,figsize=(8,8))
ax = fig.add_axes([0.1, 0.1, 0.8, 0.8], polar=True,)

thetagrids([90,45,0,315,270,225,180,135],
labels=[N,NE,E,SE,S,SO,O,NO])
theta = arange(0.0-pi/nb_secteur, 2*pi-pi/nb_secteur, 2*pi/nb_secteur)

radii = [10.,20,10,5,3,4,3,4,6,4,2,9]

width = 2*pi/nb_secteur

bars = ax.bar(theta, radii, width=width, bottom=0.0 )
for r,bar in zip(radii, bars):
bar.set_facecolor( 'blue')
bar.set_alpha(0.3)

text(1,0.69,%,transform = ax.transAxes)
show()
--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Venn diagrams

2009-02-19 Thread Jason Grout
Ian Harry wrote:
 Hi all,

 Is there any simple way in matplotlib, or in any other python library, to
 make a simple Venn diagram, I want to show three events and their
 intersections? I have tried googling for any hints but didn't find anything.

   


You can use Sage (http://www.sagemath.org or http://sagenb.org)

http://wiki.sagemath.org/interact/misc#AnInteractiveVennDiagram

(scroll down to see the picture; email me off-list if you'd like help in 
setting up an account or installing Sage; you can use Sage as a python 
library).

Even if you don't use Sage and something like the interactive Venn 
diagram listed in the URL gives you relevant code for creating such a 
thing in matplotlib.

Sage uses matplotlib in the background to actually draw the Venn diagram.

Thanks,

Jason



--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] errors when plotting random vectors

2009-02-19 Thread per freem
hi all,

i'm trying to do something extremely simple, namely print a scatter plot of
two random arrays:

import matplotlib.plt as plt
from numpy.random import *

x = rand(1,10)
scatter(x, x)

this fails with the error:

ValueError: Offsets array must be Nx2

what is happening here? are arrays somehow weird? do they not behave like
lists? any info on this will be greatly appreciated.

thank you.
--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] making points cross in simple plots

2009-02-19 Thread per freem
hi all,

when plotting a simple scatter plot in matlab, points that overlap will
cross in each other -- if i plot

scatter(randn(1,1000),randn(1,1000))

then no point will be fully on top of the other -- if they overlap, then
their edges will cross and they will look like tiny venn diagrams.

in matplotlib, this is not the case, and points that overlap are placed on
top of each other. for example if i use:
x = randn(1,1000)
plot(x, x, 'bo')

how can i fix it so that it looks like matlab and points cross?

more importantly, the above command in matplotlib generates many many line
objects and takes forever to render. if i don't specify 'bo' and simply call
plot(x, x, 'o') it makes every point in a *different color*. why is that?
how can i change that? i feel like i must be doing something wrong here.

 thanks.
--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] errors when plotting random vectors

2009-02-19 Thread Eric Firing
per freem wrote:
 hi all,
 
 i'm trying to do something extremely simple, namely print a scatter plot 
 of two random arrays:
 
 import matplotlib.plt as plt
 from numpy.random import *
 
 x = rand(1,10)
 scatter(x, x)
 
 this fails with the error:
 
 ValueError: Offsets array must be Nx2
 
 what is happening here? are arrays somehow weird? do they not behave 
 like lists? any info on this will be greatly appreciated.

Your x is 2-D; what you want is rand(10); or you can do 
scatter(x.ravel(), x.ravel()).

Your example does point to a bug in scatter, however; it should not be 
failing with an obscure error message like that.  (In mpl from svn trunk 
it still fails, but with a different obscure error message.)  I don't 
know any good reason why it should not be able to handle the 2-D inputs. 
  I will take a look.

Eric


 
 thank you.
 
 
 
 
 --
 Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
 -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
 -Strategies to boost innovation and cut costs with open source participation
 -Receive a $600 discount off the registration fee with the source code: SFAD
 http://p.sf.net/sfu/XcvMzF8H
 
 
 
 
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] making points cross in simple plots

2009-02-19 Thread Eric Firing
per freem wrote:
 hi all,
 
 when plotting a simple scatter plot in matlab, points that overlap will 
 cross in each other -- if i plot
 
 scatter(randn(1,1000),randn(1,1000))
 
 then no point will be fully on top of the other -- if they overlap, 
 then their edges will cross and they will look like tiny venn diagrams.
 
 in matplotlib, this is not the case, and points that overlap are placed 
 on top of each other. for example if i use:
 x = randn(1,1000)
 plot(x, x, 'bo')
 
 how can i fix it so that it looks like matlab and points cross?

So you want the interiors of the points to be transparent?  Add the 
keyword argument mfc='none'.  I may be misunderstanding the desired 
effect, however.

 
 more importantly, the above command in matplotlib generates many many 
 line objects and takes forever to render. if i don't specify 'bo' and 

Again, you are using 2-D arrays when you should be using 1-D.  In 
matlab, everything is a 2-D matrix (or it used to be, until higher 
dimensions were clumsily patched in).  Numpy is designed to use as many 
or as few dimensions as you need.  Mpl plot(x, y) with x and y being MxN 
is assuming each of the N columns is a line, so it is plotting N 
lines--as well as cycling through the colors, one per line, if you 
don't explicitly give a color.

 simply call plot(x, x, 'o') it makes every point in a *different color*. 
 why is that? how can i change that? i feel like i must be doing 
 something wrong here.

It's just a Matlab hangover--a common malady, painful but rarely fatal.

Eric

--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] find the projected distance between two curves

2009-02-19 Thread Andrew Straw
G. Allegri wrote:
 Hello list,
 I'm completely new to matplotlib and I'm not a computer scientist (not
 a good starting point!) but I need to solve a geometric/graphical
 problem.
 I've been asked to find a method, in Python, to find the distance
 between a 2D polynomial curve, derived from least squares
 interpolation on a set of points, and a curve locallly interpolating
 another set of points.

Do you really need the distance to be relative to the interpolated 
curve? Why not to the points which are being interpolated? Then the 
answer is just:

Sum_i dist(point_i,polynomial_curve)

Where dist() can be arrived at in closed form...

Otherwise, I guess it would depend on the interpolation, which you 
didn't really specify.

 
  - the starting line is a smooth line, while the second should
 describe a path passing exactly thorugh the given points.
  - the distance should be the one along the normal to the first line
 
 I attach a sketch to explain this.
 
 Is there an heuristic, an algorithm, to solve this problem in an
 efficient way (I have to apply it to thousands couples of sets from
 sonar and seismic acquisitions)? Is the mapltolip API useful for this?
 
 Thanks in advance,
 Giovanni
 
 
 
 
 
 
 
 --
 Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
 -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
 -Strategies to boost innovation and cut costs with open source participation
 -Receive a $600 discount off the registration fee with the source code: SFAD
 http://p.sf.net/sfu/XcvMzF8H
 
 
 
 
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users