Changeset 9690


Ignore:
Timestamp:
Feb 25, 2015, 9:32:56 AM (9 years ago)
Author:
davies
Message:

Fixing some issues in plot_utils.plot_triangles

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_core/anuga/utilities/plot_utils.py

    r9660 r9690  
    11661166        k2=p.vols[i][1]
    11671167        k3=p.vols[i][2]
    1168         if not adjustLowerLeft:
    1169             vertices.append([ [p.x[k1], p.y[k1]], [p.x[k2], p.y[k2]], [p.x[k3], p.y[k3]] ])
    1170         else:
    1171             vertices.append([ [p.x[k1]+x0, p.y[k1]+y0], [p.x[k2]+x0, p.y[k2]+y0], [p.x[k3]+x0, p.y[k3]+y0] ])
     1168
     1169        tri_coords = numpy.array([ [p.x[k1], p.y[k1]], [p.x[k2], p.y[k2]], [p.x[k3], p.y[k3]] ])
     1170        if adjustLowerLeft:
     1171            tri_coords[:,0] = tri_coords[:,0] + x0
     1172            tri_coords[:,1] = tri_coords[:,1] + y0
     1173
     1174        vertices.append(tri_coords)
    11721175     
    11731176    # Make PolyCollection
    11741177    if values is None:
    1175         all_poly = PolyCollection( vertices, array = numpy.zeros(len(p.vols)),
     1178        all_poly = PolyCollection( vertices, array = numpy.zeros(len(vertices)),
    11761179            edgecolors=edgecolors)
    11771180        all_poly.set_facecolor('none')
    11781181    else:
    1179         assert len(values)==len(p.vols), 'len(values) must either be 1, or the same as len(p.vols)'
    1180         all_poly = PolyCollection( vertices, array = values, cmap = values_cmap, edgecolors=edgecolors)
     1182        msg = 'len(values) must either be 1, or the same as len(p.vols)'
     1183        assert len(values)==len(p.vols), msg
     1184        all_poly = PolyCollection( vertices, array = values, cmap = values_cmap,
     1185            edgecolors=edgecolors)
    11811186
    11821187    # Add to plot
Note: See TracChangeset for help on using the changeset viewer.