def to_polycollection(self, *args, **kwargs):
from matplotlib import collections<EOL>nodes, elements = self.nodes, self.elements.reset_index()<EOL>verts = []<EOL>index = []<EOL>for etype, group in elements.groupby([("<STR_LIT:type>", "<STR_LIT>", "<STR_LIT>")]):<EOL><INDENT>index += list(group.index)<EOL>nvert = ELEMENTS[etype].nvert<EOL>conn = group.conn.values[:, :nvert].flatten()<EOL>coords = nodes.coords[["<STR_LIT:x>", "<STR_LIT:y>"]].loc[conn].values.reshape(<EOL>len(group), nvert, <NUM_LIT:2>)<EOL>verts += list(coords)<EOL><DEDENT>verts = np.array(verts)<EOL>verts= verts[np.argsort(index)]<EOL>return collections.PolyCollection(verts, *args,**kwargs )<EOL>
Returns the mesh as matplotlib polygon collection. (tested only for 2D meshes)