MeshPlotter

class compas_plotters.MeshPlotter(mesh, **kwargs)[source]

Bases: compas_plotters.plotter.Plotter

Plotter for the visualisation of COMPAS meshes.

Parameters

mesh (object) – The mesh to plot.

Attributes
  • title (str) – Title of the plot.

  • mesh (object) – The mesh to plot.

  • vertexcollection (object) – The matplotlib collection for the mesh vertices.

  • edgecollection (object) – The matplotlib collection for the mesh edges.

  • facecollection (object) – The matplotlib collection for the mesh faces.

  • defaults (dict) – Dictionary containing default attributes for vertices and edges.

Examples

This is a basic example using the default settings for all visualisation options. For more detailed examples, see the documentation of the various drawing methods listed below…

 import compas
 from compas.datastructures import Mesh
 from compas_plotters import MeshPlotter

 mesh = Mesh.from_obj(compas.get('faces.obj'))

 plotter = MeshPlotter(mesh)
 plotter.draw_vertices(text='key', radius=0.15)
 plotter.draw_edges()
 plotter.draw_faces()
 plotter.show()








.. figure:: ../../../dist/docs/plot_directive/api/generated/compas_plotters-MeshPlotter-1.png
   :class: figure-img img-fluid

         





.. figure:: ../../../dist/docs/plot_directive/api/generated/compas_plotters-MeshPlotter-1.pdf
   

         





.. image:: ../../../dist/docs/plot_directive/api/generated/compas_plotters-MeshPlotter-1.png

Notes

For more info about matplotlib, see 1.

References

1

Hunter, J. D., 2007. Matplotlib: A 2D graphics environment. Computing In Science & Engineering (9) 3, p.90-95. Available at: http://ieeexplore.ieee.org/document/4160265/citations.

Methods

__init__(mesh, **kwargs)

Initialises a plotter object

clear()

Clears the mesh plotter vertices, edges and faces.

clear_collection(collection)

Clears a matplotlib collection object.

clear_edges()

Clears the mesh plotter edges.

clear_faces()

Clears the mesh plotter faces.

clear_vertices()

Clears the mesh plotter vertices.

draw_arrows(arrows)

Draws arrows on a 2D plot.

draw_arrows2(arrows)

draw_edges([keys, width, color, text, …])

Draws the mesh edges.

draw_faces([keys, text, facecolor, …])

Draws the mesh faces.

draw_lines(lines)

Draws lines on a 2D plot.

draw_points(points)

Draws points on a 2D plot.

draw_polygons(polygons)

Draws polygons on a 2D plot.

draw_polylines(polylines)

Draw polylines on a 2D plot.

draw_vertices([keys, radius, text, …])

Draws the mesh vertices.

gifified(func, tempfolder, outfile[, pattern])

Create a context for making animated gifs using a callback for updating the plot.

highlight_path(path[, edgecolor, edgetext, …])

register_listener(listener)

Register a listener for pick events.

save(filepath, **kwargs)

Saves the plot to a file.

save_gif(filepath, images[, delay, loop])

Save a series of images as an animated gif.

show([autoscale])

Displays the plot.

top()

Bring the plotting window to the top.

update([pause])

Updates and pauses the plot.

update_edges()

Updates the plotter edge collection based on the mesh.

update_faces([facecolor])

Updates the plotter face collection based on the mesh.

update_linecollection(collection, segments)

Updates a line collection.

update_pointcollection(collection, centers)

Updates the location and radii of a point collection.

update_polygoncollection(collection, polygons)

update_vertices([radius])

Updates the plotter vertex collection based on the current state of the mesh.