### Email Archive: matplotlib-users (read-only)

 Re[2]: [Matplotlib-users] highlighting? From: Alan G Isaac - 2005-07-07 20:13 ```Jeff wrote: >> I was having some difficulty filling between two vertical >> lines, I don't think I can use axvline() with fill()? On Thu, 23 Jun 2005, John Hunter apparently wrote: > It sounds like axvspan is what you want ... if all you > want is shading across the vertical extent over an xrange, > axvspan is the function for you, Can this work directly with dates? E.g., the following works but is non-intuitive: import pylab import datetime d1 = datetime.date( 1995, 1, 1 ) d2 = datetime.date( 2004, 1, 1 ) delta = datetime.timedelta(days=365) dates = pylab.drange(d1,d2,delta) y = pylab.rand(len(dates)) pylab.axvspan(dates[2],dates[3]) pylab.plot_date(dates, y, 'r-') pylab.show() Thanks, Alan Isaac ```

 [Matplotlib-users] highlighting? From: Jeff Peery - 2005-06-22 15:16 ```Hello, I'm plotting a simple xy plot and I'd like to highlight regions that are above a threshold, say for example all points y>=1. The method I am thinking of applying is getting the x,y position of the point that is above the threshold and filling the region between two vertical lines that are right and left of the point with a bright color. I was having some difficulty filling between two vertical lines, I don't think I can use axvline() with fill()? Is there a more efficient way to do this... maybe creating a filled shape behind the highlight points? Any help would be much appreciated! Thanks. Jeff ```
 Re: [Matplotlib-users] highlighting? From: John Hunter - 2005-06-23 14:35 ```>>>>> "Jeff" == Jeff Peery writes: Jeff> Hello, Jeff> I'm plotting a simple xy plot and I'd like to highlight Jeff> regions that are above a threshold, say for example all Jeff> points y>=1. The method I am thinking of applying is Jeff> getting the x,y position of the point that is above the Jeff> threshold and filling the region between two vertical lines Jeff> that are right and left of the point with a bright color. Jeff> I was having some difficulty filling between two vertical Jeff> lines, I don't think I can use axvline() with fill()? It sounds like axvspan is what you want def axvspan(self, xmin, xmax, ymin=0, ymax=1, **kwargs): """ AXVSPAN(xmin, xmax, ymin=0, ymax=1, **kwargs) axvspan : Axis Vertical Span. xcoords are in data units and y coords are in axes (relative 0-1) units Draw a vertical span (regtangle) from xmin to xmax. With the default values of ymin=0 and ymax=1, this always span the yrange, regardless of the ylim settings, even if you change them, eg with the ylim command. That is, the vertical extent is in axes coords: 0=bottom, 0.5=middle, 1.0=top but the y location is in data coordinates. kwargs are the kwargs to Patch, eg antialiased, aa linewidth, lw edgecolor, ec facecolor, fc the terms on the right are aliases return value is the patches.Polygon instance. # draw a vertical green translucent rectangle from x=1.25 to 1.55 that # spans the yrange of the axes axvspan(1.25, 1.55, facecolor='g', alpha=0.5) For another approach, see examples/fill*.py, in particular examples/fill_between.py. But if all you want is shading across the vertical extent over an xrange, axvspan is the function for you,\. JDH ```
 Re[2]: [Matplotlib-users] highlighting? From: Alan G Isaac - 2005-07-07 20:13 ```Jeff wrote: >> I was having some difficulty filling between two vertical >> lines, I don't think I can use axvline() with fill()? On Thu, 23 Jun 2005, John Hunter apparently wrote: > It sounds like axvspan is what you want ... if all you > want is shading across the vertical extent over an xrange, > axvspan is the function for you, Can this work directly with dates? E.g., the following works but is non-intuitive: import pylab import datetime d1 = datetime.date( 1995, 1, 1 ) d2 = datetime.date( 2004, 1, 1 ) delta = datetime.timedelta(days=365) dates = pylab.drange(d1,d2,delta) y = pylab.rand(len(dates)) pylab.axvspan(dates[2],dates[3]) pylab.plot_date(dates, y, 'r-') pylab.show() Thanks, Alan Isaac ```