Plotly Implementation

This module provides Plotly visualization implementation for NURBS-Python.

Note

Please make sure that you have installed plotly package before using this visualization module.

Class Reference

class geomdl.visualization.VisPlotly.VisConfig(**kwargs)

Bases: geomdl.vis.VisConfigAbstract

Configuration class for Plotly visualization module.

This class is only required when you would like to change the visual defaults of the plots and the figure, such as hiding control points plot or legend.

The VisPlotly module has the following configuration variables:

  • ctrlpts (bool): Control points polygon/grid visibility. Default: True
  • evalpts (bool): Curve/surface points visibility. Default: True
  • bbox (bool): Bounding box visibility. Default: False
  • legend (bool): Figure legend visibility. Default: True
  • axes (bool): Axes and figure grid visibility. Default: True
  • trims (bool): Trim curves visibility. Default: True
  • axes_equal (bool): Enables or disables equal aspect ratio for the axes. Default: True
  • line_width (int): Thickness of the lines on the figure. Default: 2
  • figure_size (list): Size of the figure in (x, y). Default: [800, 600]
  • trim_size (int): Size of the trim curves. Default: 20

The following example illustrates the usage of the configuration class.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# Create a surface (or a curve) instance
surf = NURBS.Surface()

# Skipping degree, knot vector and control points assignments

# Create a visualization configuration instance with no legend, no axes and no control points grid
vis_config = VisPlotly.VisConfig(legend=False, axes=False, ctrlpts=False)

# Create a visualization method instance using the configuration above
vis_obj = VisPlotly.VisSurface(vis_config)

# Set the visualization method of the surface object
surf.vis = vis_obj

# Plot the surface
surf.render()

Please refer to the Examples Repository for more details.

class geomdl.visualization.VisPlotly.VisCurve2D(config=<geomdl.visualization.VisPlotly.VisConfig object>, **kwargs)

Bases: geomdl.vis.VisAbstract

Plotly visualization module for 2D curves.

add(ptsarr, plot_type, name='', color='', idx=0)

Adds points sets to the visualization instance for plotting.

Parameters:
  • ptsarr (list, tuple) – control or evaluated points
  • plot_type (str) – type of the plot, e.g. ctrlpts, evalpts, bbox, etc.
  • name (str) – name of the plot displayed on the legend
  • color (int) – plot color
  • color – plot index
animate(**kwargs)

Generates animated plots (if supported).

If the implemented visualization module supports animations, this function will create an animated figure. Otherwise, it will call render() method by default.

clear()

Clears the points, colors and names lists.

ctrlpts_offset

Defines an offset value for the control points grid plots

Only makes sense to use with surfaces with dense control points grid.

Getter:Gets the offset value
Setter:Sets the offset value
Type:float
render(**kwargs)

Plots the curve and the control points polygon.

size(plot_type)

Returns the number of plots defined by the plot type.

Parameters:plot_type (str) – plot type
Returns:number of plots defined by the plot type
Return type:int
vconf

User configuration class for visualization

Getter:Gets the user configuration class
Type:vis.VisConfigAbstract
class geomdl.visualization.VisPlotly.VisCurve3D(config=<geomdl.visualization.VisPlotly.VisConfig object>, **kwargs)

Bases: geomdl.vis.VisAbstract

Plotly visualization module for 3D curves.

add(ptsarr, plot_type, name='', color='', idx=0)

Adds points sets to the visualization instance for plotting.

Parameters:
  • ptsarr (list, tuple) – control or evaluated points
  • plot_type (str) – type of the plot, e.g. ctrlpts, evalpts, bbox, etc.
  • name (str) – name of the plot displayed on the legend
  • color (int) – plot color
  • color – plot index
animate(**kwargs)

Generates animated plots (if supported).

If the implemented visualization module supports animations, this function will create an animated figure. Otherwise, it will call render() method by default.

clear()

Clears the points, colors and names lists.

ctrlpts_offset

Defines an offset value for the control points grid plots

Only makes sense to use with surfaces with dense control points grid.

Getter:Gets the offset value
Setter:Sets the offset value
Type:float
render(**kwargs)

Plots the curve and the control points polygon.

size(plot_type)

Returns the number of plots defined by the plot type.

Parameters:plot_type (str) – plot type
Returns:number of plots defined by the plot type
Return type:int
vconf

User configuration class for visualization

Getter:Gets the user configuration class
Type:vis.VisConfigAbstract
class geomdl.visualization.VisPlotly.VisSurface(config=<geomdl.visualization.VisPlotly.VisConfig object>, **kwargs)

Bases: geomdl.vis.VisAbstract

Plotly visualization module for surfaces.

Triangular mesh plot for the surface and wireframe plot for the control points grid.

add(ptsarr, plot_type, name='', color='', idx=0)

Adds points sets to the visualization instance for plotting.

Parameters:
  • ptsarr (list, tuple) – control or evaluated points
  • plot_type (str) – type of the plot, e.g. ctrlpts, evalpts, bbox, etc.
  • name (str) – name of the plot displayed on the legend
  • color (int) – plot color
  • color – plot index
animate(**kwargs)

Generates animated plots (if supported).

If the implemented visualization module supports animations, this function will create an animated figure. Otherwise, it will call render() method by default.

clear()

Clears the points, colors and names lists.

ctrlpts_offset

Defines an offset value for the control points grid plots

Only makes sense to use with surfaces with dense control points grid.

Getter:Gets the offset value
Setter:Sets the offset value
Type:float
render(**kwargs)

Plots the surface and the control points grid.

size(plot_type)

Returns the number of plots defined by the plot type.

Parameters:plot_type (str) – plot type
Returns:number of plots defined by the plot type
Return type:int
vconf

User configuration class for visualization

Getter:Gets the user configuration class
Type:vis.VisConfigAbstract
class geomdl.visualization.VisPlotly.VisVolume(config=<geomdl.visualization.VisPlotly.VisConfig object>, **kwargs)

Bases: geomdl.vis.VisAbstract

Plotly visualization module for volumes.

add(ptsarr, plot_type, name='', color='', idx=0)

Adds points sets to the visualization instance for plotting.

Parameters:
  • ptsarr (list, tuple) – control or evaluated points
  • plot_type (str) – type of the plot, e.g. ctrlpts, evalpts, bbox, etc.
  • name (str) – name of the plot displayed on the legend
  • color (int) – plot color
  • color – plot index
animate(**kwargs)

Generates animated plots (if supported).

If the implemented visualization module supports animations, this function will create an animated figure. Otherwise, it will call render() method by default.

clear()

Clears the points, colors and names lists.

ctrlpts_offset

Defines an offset value for the control points grid plots

Only makes sense to use with surfaces with dense control points grid.

Getter:Gets the offset value
Setter:Sets the offset value
Type:float
render(**kwargs)

Plots the evaluated and the control points.

size(plot_type)

Returns the number of plots defined by the plot type.

Parameters:plot_type (str) – plot type
Returns:number of plots defined by the plot type
Return type:int
vconf

User configuration class for visualization

Getter:Gets the user configuration class
Type:vis.VisConfigAbstract