Screenshot instructions:
Windows
Mac
Red Hat Linux
Ubuntu
Click URL instructions:
Rightclick on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)
From: John Hunter <jdhunter@ac...>  20040928 16:38:38

>>>>> "Andrew" == Andrew Straw <strawman@...> writes: Andrew> The fill() command itself does work if you give it Andrew> coordinates for a closed polygon. This draws a filled Andrew> spiral: Of course (slaps self on forehead). So my example rewritten would be rewritten using the cleaner from matplotlib.matlab import * x1 = arange(0, 2, 0.01) y1 = sin(2*pi*x1) y2 = sin(4*pi*x1) + 2 # reverse x and y2 so the polygon fills in order x = concatenate( (x1,x1[::1]) ) y = concatenate( (y1,y2[::1]) ) p = fill(x, y, facecolor='g') set(p, alpha=0.5) show() I took the liberty of adding your example to CVS in the examples subdir as examples/fill_spiral.py. Thanks! JDH 
From: <replytodirk@we...>  20040928 11:44:09

I want to fill the area between two curves with a color (incl. alpha channel, I use the agg backend). fill() seems to fill only the area between the xaxis and one curve  at least I found no way for filling only the area between two graphs. Is there a way for doing so at all? Or do I have to use another graphic library for this kind of fill_between()? Dirk ________________________________________________________________ Verschicken Sie romantische, coole und witzige Bilder per SMS! Jetzt neu bei WEB.DE FreeMail: http://freemail.web.de/?mc=021193 
From: John Hunter <jdhunter@ac...>  20040928 13:04:37

>>>>> "Dirk" == <replytodirk@...> writes: Dirk> I want to fill the area between two curves with a color Dirk> (incl. alpha channel, I use the agg backend). fill() seems Dirk> to fill only the area between the xaxis and one curve  at Dirk> least I found no way for filling only the area between two Dirk> graphs. Is there a way for doing so at all? Or do I have to Dirk> use another graphic library for this kind of fill_between()? All of the matplotlib plot commands create primitive objects (lines.Line2D, patches.Rectangle, patches.Polygon, text.Text). If a plot command doesn't suit your needs, you can roll your own by creating the right kind of primitive object. Here is a fill_between implementation from matplotlib.matlab import * from matplotlib.patches import Polygon def fill_between(ax, x, y1, y2, **kwargs): # add x,y2 in reverse order for proper polygon filling verts = zip(x,y1) + [(x[i], y2[i]) for i in range(len(x)1,1,1)] poly = Polygon(verts, **kwargs) ax.add_patch(poly) ax.autoscale_view() return poly x = arange(0, 2, 0.01) y1 = sin(2*pi*x) y2 = sin(4*pi*x) + 2 ax = gca() p = fill_between(ax, x, y1, y2, facecolor='g') p.set_alpha(0.5) show() Hope this helps, JDH 
From: Andrew Straw <strawman@as...>  20040928 16:15:27

On Sep 28, 2004, at 5:15 AM, John Hunter wrote: >>>>>> "Dirk" == <replytodirk@...> writes: > > Dirk> I want to fill the area between two curves with a color > Dirk> (incl. alpha channel, I use the agg backend). fill() seems > Dirk> to fill only the area between the xaxis and one curve  at > Dirk> least I found no way for filling only the area between two > Dirk> graphs. Is there a way for doing so at all? Or do I have to > Dirk> use another graphic library for this kind of fill_between()? > > All of the matplotlib plot commands create primitive objects > (lines.Line2D, patches.Rectangle, patches.Polygon, text.Text). If a > plot command doesn't suit your needs, you can roll your own by > creating the right kind of primitive object. Here is a fill_between > implementation The fill() command itself does work if you give it coordinates for a closed polygon. This draws a filled spiral: from matplotlib.matlab import * from numarray import * theta = arange(0,8*pi,0.1) a=1 b=.2 for dt in arange(0,2*pi,pi/2.0): x = a*cos( theta+dt )*exp(b*theta) y = a*sin( theta+dt )*exp(b*theta) dt = dt+pi/4.0 x2 = a*cos( theta+dt )*exp(b*theta) y2 = a*sin( theta+dt )*exp(b*theta) xf = concatenate( (x,x2[::1]) ) yf = concatenate( (y,y2[::1]) ) p1=fill(xf,yf) show() 
From: John Hunter <jdhunter@ac...>  20040928 16:38:38

>>>>> "Andrew" == Andrew Straw <strawman@...> writes: Andrew> The fill() command itself does work if you give it Andrew> coordinates for a closed polygon. This draws a filled Andrew> spiral: Of course (slaps self on forehead). So my example rewritten would be rewritten using the cleaner from matplotlib.matlab import * x1 = arange(0, 2, 0.01) y1 = sin(2*pi*x1) y2 = sin(4*pi*x1) + 2 # reverse x and y2 so the polygon fills in order x = concatenate( (x1,x1[::1]) ) y = concatenate( (y1,y2[::1]) ) p = fill(x, y, facecolor='g') set(p, alpha=0.5) show() I took the liberty of adding your example to CVS in the examples subdir as examples/fill_spiral.py. Thanks! JDH 
From: <replytodirk@we...>  20040928 16:09:58

John Hunter: Normally I wouldn't waste bandwith in a mailinglist by sending neither a question nor an answer, but in this case I feel the urge to thank you for your support. Your function does exactly what I need and you even gave a hint on how to implement such functional extensions. On top of that, the answer came an hour after I sent the question :) > All of the matplotlib plot commands create primitive objects > (lines.Line2D, patches.Rectangle, patches.Polygon, text.Text). If a > plot command doesn't suit your needs, you can roll your own by > creating the right kind of primitive object. [...] Do I have to dive into the class description at http://matplotlib.sourceforge.net/classdocs.html to get this informations or is there a more userfriendly description of the matplotlib internals? Thanks Dirk  Original Message  From: "John Hunter" <jdhunter@...> To: <replytodirk@...> Cc: <matplotlibusers@...> Sent: Tuesday, September 28, 2004 2:15 PM Subject: Re: [Matplotlibusers] fill area between two curves? fill_between? > >>>>> "Dirk" == <replytodirk@...> writes: > > Dirk> I want to fill the area between two curves with a color > Dirk> (incl. alpha channel, I use the agg backend). fill() seems > Dirk> to fill only the area between the xaxis and one curve  at > Dirk> least I found no way for filling only the area between two > Dirk> graphs. Is there a way for doing so at all? Or do I have to > Dirk> use another graphic library for this kind of fill_between()? > > All of the matplotlib plot commands create primitive objects > (lines.Line2D, patches.Rectangle, patches.Polygon, text.Text). If a > plot command doesn't suit your needs, you can roll your own by > creating the right kind of primitive object. Here is a fill_between > implementation > > from matplotlib.matlab import * > from matplotlib.patches import Polygon > > def fill_between(ax, x, y1, y2, **kwargs): > # add x,y2 in reverse order for proper polygon filling > verts = zip(x,y1) + [(x[i], y2[i]) for i in range(len(x)1,1,1)] > poly = Polygon(verts, **kwargs) > ax.add_patch(poly) > ax.autoscale_view() > return poly > > x = arange(0, 2, 0.01) > y1 = sin(2*pi*x) > y2 = sin(4*pi*x) + 2 > ax = gca() > > p = fill_between(ax, x, y1, y2, facecolor='g') > p.set_alpha(0.5) > show() > > Hope this helps, > JDH > 
From: John Hunter <jdhunter@ac...>  20040928 17:37:39

>>>>> "Dirk" == <replytodirk@...> writes: Dirk> John Hunter: Normally I wouldn't waste bandwith in a Dirk> mailinglist by sending neither a question nor an answer, Dirk> but in this case I feel the urge to thank you for your Dirk> support. Your function does exactly what I need and you even Dirk> gave a hint on how to implement such functional Dirk> extensions. On top of that, the answer came an hour after I Dirk> sent the question :) Your welcome... Dirk> Do I have to dive into the class description at Dirk> http://matplotlib.sourceforge.net/classdocs.html to get this Dirk> informations or is there a more userfriendly description of Dirk> the matplotlib internals? I think the best way, after studying the examples in the examples directory of the src distribution, is to read through the code in axes.py. Almost all of the plotting functions in matplotlib.matlab are wrappers for axes plotting functions. Eg scatter wraps matplotlib.Axes.scatter, plot wraps matplotlib.Axes.plot and so on. Most of the axes plotting functions in turn create the primitive objects that actually make up the plot. Axes.plot is one of the more complicated functions, since it does a lot of variable length argument processing, so it is probably not the best place to start. If you have a link to the classdocs open, as you read through the axes code, you can read the docs for the functions that are being called. JDH 
From: <fccoelho@fi...>  20040929 15:51:53

On Tuesday 28 September 2004 16:48, John Hunter wrote: > >>>>> "Dirk" == <replytodirk@...> writes: > > Dirk> John Hunter: Normally I wouldn't waste bandwith in a > Dirk> mailinglist by sending neither a question nor an answer, > Dirk> but in this case I feel the urge to thank you for your > Dirk> support. Your function does exactly what I need and you even > Dirk> gave a hint on how to implement such functional > Dirk> extensions. On top of that, the answer came an hour after I > Dirk> sent the question :) > > Your welcome... Hi John, I agree with Dirk on the precision and promptness of your responses to all our questions. I am always learning new things about matplolib (MPL) through theses Q&A exchanges. But since topic of bandwidth usage came up in this thread, for the sake of saving not only Sourceforge's but also JDH's bandwidth, I believe a documentation project for MPL should be started. I understand that you might not want to commit effort to document MPL now, since it's still under pretty intense development. However, starting a Wiki documentation project might be a good idea, since the user community could help by adding short tutorials and recipes derived from their own experience with MPL. Moreover, the wiki could slowly evolve into a full blown documentation project. What do you think? cheers, Flavio  
Sign up for the SourceForge newsletter:
No, thanks