Plot Style¶
This module provides classes for defining style of plots.
- class pyrigi.plot_style.PlotStyle(vertex_size=300, vertex_color='#ff8c00', vertex_labels=True, vertex_shape='o', edge_width=2.5, edge_color='black', edge_style='solid', flex_width=1.5, flex_length=0.15, flex_color='limegreen', flex_style='solid', flex_arrow_size=20, stress_color='orangered', stress_fontsize=10, stress_rotate_labels=True, stress_normalization=False, font_size=12, font_color='whitesmoke', canvas_width=6.4, canvas_height=4.8, dpi=175)[source]¶
Bases:
objectClass for defining the plot style.
For options specific to 2D or 3D plots, see
PlotStyle2DandPlotStyle3D. For specifying different colors for each edge etc., seeFramework.plot2D()andFramework.plot3D().Note that the parameters can be used directly in plot methods like
Graph.plot()orFramework.plot2D().- Parameters:
vertex_color (
str) – The color of the vertices given by name like"green"or hex"#00ff00".vertex_labels (
bool) – IfTrue(default), vertex labels are displayed.vertex_shape (
str) – The shape of the vertices specified asmatplotlib.pyplot.scatter()marker, one ofso^>v<dph8.edge_color (
str) – The color of all edges given as a string (name like"green"or hex"#00ff00"). For specifying a different color for each edge, see parameteredge_colors_custominFramework.plot2D().edge_style (
str) – Edge line style:-/solid,--/dashed,-./dashdotor:/dotted.flex_width (
float|int) – The width of the infinitesimal flex’s arrow tail.flex_color (
str) – The color of the infinitesimal flex.flex_style (
str) – Line Style:-/solid,--/dashed,-./dashdotor:/dotted.flex_length (
float|int) – Length of the displayed flex relative to the total canvas diagonal in percent.flex_arrow_size (
int) – The size of the arrowhead’s length and width.stress_color (
str) – The color of the font used to label the edges with stresses.stress_fontsize (
int) – Fontsize of the stress labels.stress_rotate_labels (
bool) – A boolean indicating whether the stress label should be rotated.stress_normalization (
bool) – A boolean indicating whether the stress values should be turned into floating point numbers. IfTrue, the stress is automatically normalized.font_size (
int) – The size of the font used for the labels.font_color (
str) – The color of the font used for the labels.canvas_width (
float|int) – The width of the canvas in inches.canvas_height (
float|int) – The height of the canvas in inches.dpi (
int) – DPI (dots per inch) for the plot.
Examples
>>> from pyrigi import Graph >>> G = Graph([(0,1), (1,2), (2,3), (0,3)]) >>> plot_style = PlotStyle(vertex_color="#FF0000", edge_color="black", vertex_size=50) >>> G.plot(plot_style)
To change the plot style later, use the
update()method:>>> plot_style.update(vertex_color="#00FF00") >>> G.plot(plot_style)
Or assign to the attributes:
>>> plot_style.vertex_color = "blue" >>> G.plot(plot_style)
- class pyrigi.plot_style.PlotStyle2D(aspect_ratio=1.0, edges_as_arcs=False, arc_angle=0.5235987755982988, **kwargs)[source]¶
Bases:
PlotStyleClass for defining the 2D plot style.
- Parameters:
edges_as_arcs (
bool) – IfTrue(default), the edges are displayed as arcs.arc_angle (
float|int) – Only ifedges_as_arcs=True: the pitch of the edge arcs in radians. For setting different values for individual edges, seearc_angles_dictinFramework.plot2D().
Examples
>>> from pyrigi import Framework, PlotStyle2D >>> F = Framework.Complete([(0,1), (1,2), (0,2)]) >>> plot_style_2d = PlotStyle2D(aspect_ratio=1, edges_as_arcs=True, arc_angle=np.pi/6) >>> F.plot2D(plot_style_2d)
To update the plot style, you can assign to the attributes:
>>> plot_style_2d.aspect_ratio = 0.75 >>> plot_style_2d.edges_as_arcs = False >>> F.plot2D(plot_style_2d)
Or use the
update()method:>>> plot_style_2d.update(aspect_ratio=1.0, edges_as_arcs=True, arc_angle=np.pi/4) >>> F.plot2D(plot_style_2d)
- class pyrigi.plot_style.PlotStyle3D(padding=0.01, axis_scales=(1.0, 1.0, 1.0), **kwargs)[source]¶
Bases:
PlotStyleClass for defining the 3D plot style.
- Parameters:
Examples
>>> from pyrigi import Framework, PlotStyle3D >>> F = Framework.Complete([(0,1,2), (1,2,3), (2,3,0), (0,3,1)]) >>> plot_style_3d = PlotStyle3D(padding=0.05, axis_scales=(2.0, 2.0, 2.0)) >>> F.plot(plot_style_3d)
To update the plot style, you can assign to the attributes:
>>> plot_style_3d.padding = 0.10 >>> plot_style_3d.axis_scales = (1.0, 2, 1.0) >>> F.plot(plot_style_3d)
Or use the
update()method:>>> plot_style_3d.update(padding=0.15, axis_scales=(1.0, 1.0, 3))