variable line thickness in a plot

Hi, does anyone know of a way to create lines with variable thickness and color when doing a plot?

Basically, I’d like to have a third dimension represented using thickness. The API for the plot function states that the line thickness can only be a single floating point number.

Thanks

I don't know if this is the easiest way, but it can be done with clever use of fill:

from pylab import *

x = linspace(0,10,101)
y = cos(x)
z = sin(3*x)+2
zn = 0.05*z

xs, ys = mlab.poly_between(x, y-zn, y+zn)
fill(xs, ys)
show()

Best Regards

···

On Tue, Mar 11, 2008 at 12:45:21PM -0700, eliss wrote:

   Hi, does anyone know of a way to create lines with variable thickness
   and color when doing a plot?
   Basically, I'd like to have a third dimension represented using
   thickness. The API for the plot function states that the line thickness
   can only be a single floating point number.
   Thanks

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

--
Troels Kofoed Jacobsen
tkjacobsen@...287...
tel: +45 20880798

Really? Try

    plot([1,2,3], lw=math.pi)

cheers,
steve

···

On Tue, Mar 11, 2008 at 12:45:21PM -0700, eliss wrote:

The API for the plot function states that the line thickness can only be a
single floating point number.

Thanks for the reply. I couldn’t find the “poly_between” function in mlab. I imported my mlab, and did dir(mlab) but that method doesn’t show up in there. I tried redownloading the latest version of matplotlib as well. Am I missing a library?

···

On 3/11/08, Troels Kofoed Jacobsen <tkjacobsen@…287…> wrote:

On Tue, Mar 11, 2008 at 12:45:21PM -0700, eliss wrote:

Hi, does anyone know of a way to create lines with variable thickness

and color when doing a plot?
Basically, I’d like to have a third dimension represented using
thickness. The API for the plot function states that the line thickness
can only be a single floating point number.

Thanks

I don’t know if this is the easiest way, but it can be done with clever use of fill:

from pylab import *

x = linspace(0,10,101)
y = cos(x)
z = sin(3x)+2
zn = 0.05
z

xs, ys = mlab.poly_between(x, y-zn, y+zn)
fill(xs, ys)
show()

Best Regards

I have version 0.91.2 of matplotlib and for me the function is there.

(I found it in the fill_between.py example)

···

On Tue, Mar 11, 2008 at 01:23:04PM -0700, eliss wrote:

   On 3/11/08, Troels Kofoed Jacobsen <[1]tkjacobsen@...287...> wrote:

     On Tue, Mar 11, 2008 at 12:45:21PM -0700, eliss wrote:
     >
     > Hi, does anyone know of a way to create lines with variable
     thickness
     > and color when doing a plot?
     > Basically, I'd like to have a third dimension represented using
     > thickness. The API for the plot function states that the line
     thickness
     > can only be a single floating point number.
     > Thanks
     I don't know if this is the easiest way, but it can be done with
     clever use of fill:
     from pylab import *
     x = linspace(0,10,101)
     y = cos(x)
     z = sin(3*x)+2
     zn = 0.05*z
     xs, ys = mlab.poly_between(x, y-zn, y+zn)
     fill(xs, ys)
     show()
     Best Regards

   Thanks for the reply. I couldn't find the "poly_between" function in
   mlab. I imported my mlab, and did dir(mlab) but that method doesn't
   show up in there. I tried redownloading the latest version of
   matplotlib as well. Am I missing a library?

References

   1. mailto:tkjacobsen@…287…

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

--
Troels Kofoed Jacobsen
tkjacobsen@...287...
tel: +45 20880798

Ah, my os did not have the latest package in the repository so I had to build it. Works now. Thanks!

···

On 3/11/08, Troels Kofoed Jacobsen <tkjacobsen@…287…> wrote:

On Tue, Mar 11, 2008 at 01:23:04PM -0700, eliss wrote:

On 3/11/08, Troels Kofoed Jacobsen <[1]tkjacobsen@gmail.com> wrote:

 On Tue, Mar 11, 2008 at 12:45:21PM -0700, eliss wrote:
 >
 >    Hi, does anyone know of a way to create lines with variable
 thickness
 >    and color when doing a plot?
 >    Basically, I'd like to have a third dimension represented using
 >    thickness. The API for the plot function states that the line
 thickness
 >    can only be a single floating point number.
 >    Thanks
 I don't know if this is the easiest way, but it can be done with
 clever use of fill:
 from pylab import *
 x = linspace(0,10,101)
 y = cos(x)
 z = sin(3*x)+2
 zn = 0.05*z
 xs, ys = mlab.poly_between(x, y-zn, y+zn)
 fill(xs, ys)
 show()
 Best Regards

Thanks for the reply. I couldn’t find the “poly_between” function in

mlab. I imported my mlab, and did dir(mlab) but that method doesn’t
show up in there. I tried redownloading the latest version of
matplotlib as well. Am I missing a library?

References

  1. mailto:tkjacobsen@…287…

This SF.net email is sponsored by: Microsoft

Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/


Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

I have version 0.91.2 of matplotlib and for me the function is there.

(I found it in the fill_between.py example)