def plot_network(network): """ Compas Network Plotter """ plotter=NetworkPlotter(network) plotter.draw_nodes(radius=0.001, text='key', fontsize=15.0, facecolor=(0, 0, 0)) plotter.draw_edges() plotter.show()
def plot(self, vertexcolor=None, edgecolor=None, vertexsize=None, edgewidth=None, vertextext=None, edgetext=None): """Plot a 2D representation of the network. Parameters ---------- vertexcolor : dict, optional A dictionary mapping vertex identifiers to colors. edgecolor : dict, optional A dictionary mapping edge identifiers to colors. vertexsize : dict, optional A dictionary mapping vertex identifiers to sizes. edgewidth : dict, optional A dictionary mapping edge identifiers to widths. vertextext : dict, optional A dictionary mappping vertex identifiers to labels. edgetext : dict, optional A dictionary mappping edge identifiers to labels. Examples -------- .. plot:: :include-source: import compas from compas.datastructures import Network network = Network.from_obj(compas.get('lines.obj')) network.plot() """ from compas_plotters import NetworkPlotter plotter = NetworkPlotter(self) plotter.draw_vertices(facecolor=vertexcolor, radius=vertexsize, text=vertextext) plotter.draw_edges(color=edgecolor, width=edgewidth, text=edgetext) plotter.show()
}) plotter = NetworkPlotter(structure, figsize=(8, 5)) plotter.draw_vertices(radius=0.005, facecolor={ i: '#ff0000' for i in structure.vertices_where({'is_fixed': True}) }) plotter.draw_lines(lines) plotter.draw_edges() def callback(X, k_i): for key in structure.vertices(): x, y, z = X[k_i[key], :] structure.set_vertex_attributes(key, 'xyz', [x, y, z]) plotter.update_edges() plotter.update(pause=0.01) drx_numpy(structure=structure, tol=0.01, refresh=20, factor=30, update=1, callback=callback, k_i=structure.key_index()) plotter.show()