From: Andrew S. <str...@as...> - 2004-03-05 12:06:05
|
G'day all! I'm back to using matplotlib after a few months away. I'm very impressed with the recent progress! I often plot the instantaneous variance of repeated recordings made under the same conditions using a shaded area to surround the mean. I'm trying to find a way to do this with matplotlib. Included below is a "filly" (fill y) function I wrote to attempt to do this. It doesn't quite work yet, and I'd like some help. (BTW, I don't know of how this would be done in Matlab, so if there's a more compatible way, I'd be happy to change the approach.) 1) How do I make the data fill the axes automatically, such as the "plot" function? 2) Is it a bug that the polygon is not filled, or am I missing something? I've only tried this in the PS backend -- I'm having troubles with the others at the moment. Also, this is using the version of matplotlib I checked out with CVS. This version fails to build the agg backend with: running build_py package init file 'ttfquery/__init__.py' not found (or not a regular file) package init file 'FontTools/__init__.py' not found (or not a regular file) package init file 'FontTools/fontTools/__init__.py' not found (or not a regular file) package init file 'FontTools/fontTools/encodings/__init__.py' not found (or not a regular file) error: package directory 'FontTools/fontTools/misc' does not exist Cheers! Andrew -=-=-=-=-=-=-= filly.py -=-=-=-=-=-=-=-= from matplotlib.matlab import * from matplotlib.patches import Rectangle, Polygon def filly(x,y1,y2,**kwargs): ax = gca() xy = [] for xi, yi in zip(x,y1): xy.append( (xi,yi) ) for xi, yi in zip(x[::-1],y2[::-1]): xy.append( (xi,yi) ) xy.append( xy[0] ) polygon = Polygon( ax.dpi, ax.bbox, xy, transx = ax.xaxis.transData, # what does this do? transy = ax.yaxis.transData, # and this?? **kwargs) ax.add_patch(polygon) return polygon figure(1) t = arange(0.0, 1.0, 0.01) s_mean = 0.5*sin(2*2*pi*t) s_lo = s_mean-0.1 s_hi = s_mean+0.1 #plot(t,s_mean,'k') filly(t,s_lo,s_hi,fill=1,facecolor='g') gca().xaxis.autoscale_view() # why doesn't this help? gca().yaxis.autoscale_view() savefig('filly') #show() |