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:
VisConfigAbstractConfiguration 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
VisPlotlymodule has the following configuration variables:ctrlpts(bool): Control points polygon/grid visibility. Default: Trueevalpts(bool): Curve/surface points visibility. Default: Truebbox(bool): Bounding box visibility. Default: Falselegend(bool): Figure legend visibility. Default: Trueaxes(bool): Axes and figure grid visibility. Default: Truetrims(bool): Trim curves visibility. Default: Trueaxes_equal(bool): Enables or disables equal aspect ratio for the axes. Default: Trueline_width(int): Thickness of the lines on the figure. Default: 2figure_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# Create a surface (or a curve) instance 2surf = NURBS.Surface() 3 4# Skipping degree, knot vector and control points assignments 5 6# Create a visualization configuration instance with no legend, no axes and no control points grid 7vis_config = VisPlotly.VisConfig(legend=False, axes=False, ctrlpts=False) 8 9# Create a visualization method instance using the configuration above 10vis_obj = VisPlotly.VisSurface(vis_config) 11 12# Set the visualization method of the surface object 13surf.vis = vis_obj 14 15# Plot the surface 16surf.render()
Please refer to the Examples Repository for more details.
- in_notebook()
- class geomdl.visualization.VisPlotly.VisCurve2D(config=<geomdl.visualization.VisPlotly.VisConfig object>, **kwargs)
Bases:
VisAbstractPlotly 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.
- property 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
- property 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:
VisAbstractPlotly 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.
- property 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
- property 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:
VisAbstractPlotly 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.
- property 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
- property 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:
VisAbstractPlotly 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.
- property 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
- property vconf
User configuration class for visualization
- Getter:
Gets the user configuration class
- Type:
vis.VisConfigAbstract