NetworkPlotter

class compas_plotters.NetworkPlotter(network, **kwargs)[source]

Bases: compas_plotters._plotter.BasePlotter

Plotter for the visualization of COMPAS Networks.

Parameters

network (compas.datastructures.Network) – The network to plot.

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

  • network (object) – The network to plot.

  • nodecollection (object) – The matplotlib collection for the network nodes.

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

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

Notes

For more info, 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.

Examples

 import compas
 from compas.datastructures import Network
 from compas_plotters import NetworkPlotter

 network = Network.from_obj(compas.get('lines.obj'))

 plotter = NetworkPlotter(network)
 plotter.draw_nodes(
     text='key',
     facecolor={key: '#ff0000' for key in network.leaves()},
     radius=0.15
 )
 plotter.draw_edges()
 plotter.show()








.. figure:: ../../../dist/docs/plot_directive/api/generated/compas_plotters-NetworkPlotter-1.png
   :class: ['plot-directive'] img-fluid figure-img
   :class: figure-img img-fluid

   
   





.. figure:: ../../../dist/docs/plot_directive/api/generated/compas_plotters-NetworkPlotter-1.pdf
   :class: ['plot-directive']
   

   
   





.. image:: ../../../dist/docs/plot_directive/api/generated/compas_plotters-NetworkPlotter-1.png
   :class: ['plot-directive']

Methods

clear()

Clears the network plotter edges and nodes.

clear_collection(collection)

Clears a matplotlib collection object.

clear_edges()

Clears the network object edges.

clear_nodes()

Clears the netwotk plotter nodes.

draw_arrows(arrows)

Draws arrows on a 2D plot.

draw_arrows2(arrows)

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

Draws the network edges.

draw_lines(lines)

Draws lines on a 2D plot.

draw_nodes([keys, radius, text, facecolor, ...])

Draws the network nodes.

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.

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

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

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 network.

update_linecollection(collection, segments)

Updates a line collection.

update_nodes([radius])

Updates the plotter node collection based on the network.

update_pointcollection(collection, centers)

Updates the location and radii of a point collection.

update_polygoncollection(collection, polygons)