from compas.geometry import Pointcloud, Translation from compas.utilities import i_to_red, pairwise from compas_plotters import Plotter plotter = Plotter(figsize=(8, 5)) pointcloud = Pointcloud.from_bounds(8, 5, 0, 10) for index, (a, b) in enumerate(pairwise(pointcloud)): artist = plotter.add(a, edgecolor=i_to_red(max(index / 10, 0.1), normalize=True)) plotter.add(b, size=10, edgecolor=(1, 0, 0)) plotter.zoom_extents() plotter.pause(1.0) @plotter.on(interval=0.1, frames=50, record=True, recording='docs/_images/tutorial/plotters_dynamic.gif', dpi=150) def move(frame): print(frame) for a, b in pairwise(pointcloud): vector = b - a a.transform(Translation.from_vector(vector * 0.1))
import random from compas.geometry import Line from compas.geometry import Pointcloud from compas.utilities import i_to_rgb, grouper from compas_plotters import Plotter plotter = Plotter(figsize=(8, 5)) pointcloud = Pointcloud.from_bounds(8, 5, 0, 10) for a, b in grouper(pointcloud, 2): line = Line(a, b) plotter.add(line, linewidth=2.0, linestyle=random.choice(['dotted', 'dashed', 'solid']), color=i_to_rgb(random.random(), normalize=True), draw_points=True) plotter.zoom_extents() plotter.show() # plotter.save('docs/_images/tutorial/plotters_line-options.png', dpi=300)
from compas.geometry import Pointcloud from compas.utilities import i_to_red, pairwise from compas_plotters import Plotter plotter = Plotter(figsize=(8, 5)) pointcloud = Pointcloud.from_bounds(8, 5, 0, 10) for index, (a, b) in enumerate(pairwise(pointcloud)): vector = b - a vector.unitize() plotter.add(vector, point=a, draw_point=True, color=i_to_red(max(index / 10, 0.1), normalize=True)) plotter.add(b, size=10, edgecolor=(1, 0, 0)) plotter.zoom_extents() plotter.show() plotter.save('docs/_images/tutorial/plotters_vector-options.png', dpi=300)
from compas.geometry import Polygon, Translation from compas_plotters import Plotter poly1 = Polygon.from_sides_and_radius_xy(5, 1.0) poly2 = Polygon.from_sides_and_radius_xy(5, 1.0).transformed(Translation.from_vector([0.5, -0.25, 0])) poly3 = Polygon.from_sides_and_radius_xy(5, 1.0).transformed(Translation.from_vector([0.75, +0.25, 0])) plotter = Plotter(figsize=(8, 5)) plotter.add(poly1, linewidth=3.0, facecolor=(0.8, 1.0, 0.8), edgecolor=(0.0, 1.0, 0.0)) plotter.add(poly2, linestyle='dashed', facecolor=(1.0, 0.8, 0.8), edgecolor=(1.0, 0.0, 0.0)) plotter.add(poly3, alpha=0.5) plotter.zoom_extents() plotter.show() # plotter.save('docs/_images/tutorial/plotters_polygon-options.png', dpi=300)