Changeset 7516


Ignore:
Timestamp:
Sep 18, 2009, 2:08:18 PM (16 years ago)
Author:
rwilson
Message:

Added polygon fill - UNTESTED!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/utilities/polygon.py

    r7511 r7516  
    695695                  figname=None,
    696696                  label=None,
     697                  alpha=None,
    697698                  verbose=False):
    698699    """ Take list of polygons and plot.
     
    709710    figname          - name to save figure to
    710711
    711     label            - title for plot
     712    label            - title for plotA
     713
     714    alpha            - transparency of polygon fill, 0.0=none, 1.0=solid
     715                       if not supplied, no fill.
    712716
    713717    Outputs:
     
    718722
    719723    from pylab import ion, hold, plot, axis, figure, legend, savefig, xlabel, \
    720                       ylabel, title, close, title
     724                      ylabel, title, close, title, fill
    721725
    722726    assert type(polygons_points) == list, \
     
    733737    if label is None:
    734738        label = ''
     739
     740    # clamp alpha to sensible range
     741    if alpha:
     742        try:
     743            alpha = float(alpha)
     744        except ValueError:
     745            alpha = None
     746        else:
     747            if alpha < 0.0:
     748                alpha = 0.0
     749            if alpha > 1.0:
     750                alpha = 1.0
    735751
    736752    n = len(polygons_points)
     
    757773        if max(y) > maxy: maxy = max(y)
    758774        plot(x,y,colour[i])
     775        if alpha:
     776            fill(x, y, colour[i], alpha=alpha)
    759777        xlabel('x')
    760778        ylabel('y')
Note: See TracChangeset for help on using the changeset viewer.