 # highlighting?

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()?

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

Jeff wrote:

I was having some difficulty filling between two vertical
lines, I don't think I can use axvline() with fill()?

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,dates)
pylab.plot_date(dates, y, 'r-')
pylab.show()

Thanks,
Alan Isaac

···

On Thu, 23 Jun 2005, John Hunter apparently wrote: