Auxiliary Plot Functions
Auxiliary functions for plotting fields and nodes.
- comfit.plot.plot_angle_field_matplotlib.plot_angle_field_matplotlib(self, angle_field, **kwargs)
Plot an angle field using matplotlib.
- Return type:
Tuple
[Figure
,Axes
]
Parameters
- selfBaseSystem
A BaseSystem (or derived) instance.
- angle_fieldnp.ndarray
The angle field values in radians.
- **kwargsAny
Keyword arguments for the plot, see https://comfitlib.com/Plotting/.
Returns
- tuple[matplotlib.figure.Figure, matplotlib.axes.Axes]
The figure and axes objects containing the plot.
- comfit.plot.plot_angle_field_plotly.plot_angle_field_plotly(self, angle_field, **kwargs)
Plot the angle field using plotly.
- Return type:
Tuple
[Figure
,dict
]
Parameters
- selfBaseSystem
A BaseSystem (or derived) instance.
- angle_fieldnp.ndarray
The angle field values to plot.
- **kwargsAny
Keyword arguments for the plot, see https://comfitlib.com/Plotting/.
Returns
- Any
The plotly figure object.
- comfit.plot.plot_complex_field_in_plane_matplotlib.plot_complex_field_in_plane_matplotlib(self, complex_field, normal_vector=None, position=None, **kwargs)
Plot the complex field in a plane perpendicular to the given normal vector.
- Return type:
Tuple
[Figure
,Axes
]
Parameters
- selfBaseSystem
A BaseSystem (or derived) instance.
- complex_fieldnp.ndarray
The complex field to be plotted.
- normal_vectornp.ndarray, optional
The normal vector of the plane. Defaults to [0,1,0].
- positionnp.ndarray, optional
The position of the plane. Defaults to the middle of the system.
- **kwargsAny
Keyword arguments for the plot, see https://comfitlib.com/Plotting/.
Returns
- tuple[Figure, Axes]
The figure and axes containing the plot.
Raises
- Exception
If the field dimension is not 3D.
- comfit.plot.plot_complex_field_in_plane_plotly.plot_complex_field_in_plane_plotly(self, complex_field, normal_vector=None, position=None, **kwargs)
Plot the complex field in a plane perpendicular to the given normal vector.
- Return type:
tuple
[Figure
,dict
]
Parameters
- selfBaseSystem
A BaseSystem (or derived) instance.
- complex_fieldnp.ndarray
The complex field to be plotted.
- normal_vectornp.ndarray, optional
The normal vector of the plane. Defaults to [0,1,0].
- positionnp.ndarray, optional
The position of the plane. Defaults to the middle of the system.
- **kwargsAny
Keyword arguments for the plot, see https://comfitlib.com/Plotting/.
Returns
- tuple[go.Figure, dict]
The figure and axes dictionary containing the plot of the complex field.
Raises
- Exception
If the dimension of the system is not 3.
- comfit.plot.plot_complex_field_matplotlib.plot_complex_field_matplotlib(self, complex_field, **kwargs)
Plot a complex field using matplotlib.
Creates a visualization of a complex field using different plotting methods depending on the dimensionality of the field.
- Return type:
Tuple
[Figure
,Axes
]
Parameters
- selfBaseSystem
A BaseSystem (or derived) instance.
- complex_fieldnp.ndarray
The complex field to plot
- **kwargsAny
Keyword arguments for the plot, see https://comfitlib.com/Plotting/
Returns
- Tuple[matplotlib.figure.Figure, matplotlib.axes.Axes]
The figure and axes objects containing the plot
Examples
>>> system.plot_complex_field_matplotlib(field, colorbar=True)
- comfit.plot.plot_complex_field_plotly.plot_complex_field_plotly(self, complex_field, **kwargs)
Plot a complex field using Plotly.
Creates a visualization of a complex field using various plotting methods depending on the dimensionality of the field.
- Return type:
Tuple
[Figure
,Dict
]
Parameters
- selfBaseSystem
A BaseSystem (or derived) instance.
- complex_fieldnp.ndarray
The complex field to plot
- **kwargsAny
Additional keyword arguments to customize the plot
Returns
- go.Figure
The Plotly figure containing the plot
- comfit.plot.plot_field_in_plane_matplotlib.plot_field_in_plane_matplotlib(self, field, normal_vector=None, position=None, **kwargs)
Plot the field in a plane perpendicular to the given normal vector.
Uses scipy.interpolate.griddata and plt.plot_trisurf to visualize the field values on a plane defined by its normal vector and a point in space.
- Return type:
Tuple
[Figure
,Axes
]
Parameters
- selfBaseSystem
A BaseSystem (or derived) instance.
- fieldnp.ndarray
The field to be plotted.
- normal_vectornp.ndarray, optional
The normal vector of the plane. Defaults to [0,1,0].
- positionnp.ndarray, optional
The position of the plane. Defaults to the middle of the system.
- **kwargsAny
Keyword arguments for the plot, see https://comfitlib.com/Plotting/.
Returns
- Tuple[matplotlib.figure.Figure, matplotlib.axes.Axes]
The figure and axes containing the plot.
Raises
- Exception
If the field dimension is not 3D.
- comfit.plot.plot_field_in_plane_plotly.plot_field_in_plane_plotly(self, field, normal_vector=None, position=None, **kwargs)
Plot the field in a plane perpendicular to the given normal vector.
Uses scipy.interpolate.griddata and plotly’s Mesh3d for visualization.
- Return type:
Tuple
[Figure
,Dict
]
Parameters
- selfBaseSystem
A BaseSystem (or derived) instance.
- fieldnp.ndarray
The field to be plotted
- normal_vectornp.ndarray, optional
The normal vector of the plane. Defaults to [0,1,0]
- positionnp.ndarray, optional
The position of the plane. Defaults to the middle of the system
- **kwargsAny
Additional keyword arguments for plot customization. See https://comfitlib.com/Plotting/
Returns
- Tuple[go.Figure, dict]
The figure object and axes dictionary containing the plot
Raises
- Exception
If the field dimension is not 3D
- comfit.plot.plot_field_matplotlib.plot_field_matplotlib(self, field, **kwargs)
Plot the given (real) field.
- Return type:
tuple
[Figure
,Axes
]
Parameters
- selfBaseSystem
A BaseSystem (or derived) instance.
- fieldnp.ndarray
The field to be plotted.
- **kwargsAny
Keyword arguments for the plot. See https://comfitlib.com/ClassBaseSystem/ for a full list of keyword arguments.
Returns
- tuple[matplotlib.figure.Figure, matplotlib.axes.Axes]
The figure containing the plot
The axes containing the plot
- comfit.plot.plot_field_plotly.plot_field_plotly(self, field, **kwargs)
Plot the given (real) field using Plotly.
- Return type:
Tuple
[Figure
,Dict
]
Parameters
- selfBaseSystem
A BaseSystem (or derived) instance.
- fieldnp.ndarray
The field to be plotted.
- **kwargsAny
Keyword arguments for the plot. See https://comfitlib.com/ClassBaseSystem/ for a full list of keyword arguments.
Returns
- Tuple[go.Figure, Dict]
A tuple containing the Plotly figure and axes dictionary.
- comfit.plot.plot_nodes_matplotlib.plot_nodes_matplotlib(self, nodes, **kwargs)
Plot the nodes of the system.
Create a matplotlib plot of the nodes in the system, including their positions, charges, velocities and Burgers vectors if available.
- Return type:
Tuple
[Figure
,Axes
]
Parameters
- selfBaseSystem
A BaseSystem (or derived) instance.
- nodesList[Dict]
List of node dictionaries containing position and property information
- **kwargsAny
Keyword arguments for customizing the plot. See https://comfitlib.com/ClassBaseSystem/ for full list.
Returns
- Tuple[plt.Figure, plt.Axes]
The figure and axes objects containing the plot
- comfit.plot.plot_nodes_plotly.plot_nodes_plotly(self, nodes, **kwargs)
Plot the nodes in the system.
- Return type:
Tuple
[Figure
,Dict
]
Parameters
- selfBaseSystem
A BaseSystem (or derived) instance.
- nodesList[Dict]
- A list of dictionaries representing nodes. Each dictionary must contain:
‘position’: The position of the node in the defect density array
- Optional keys:
‘velocity’: The velocity of the node
‘charge’: The charge of the node
‘tangent_vector’: The tangent of the node (3D only)
‘Burgers_vector’: The Burgers vector of the node (for dislocations)
- **kwargsAny
Keyword arguments for the plot. See https://comfitlib.com/ClassBaseSystem/ for a full list of keyword arguments.
Returns
- Tuple[go.Figure, Dict]
The figure object and axes dictionary containing the plot configuration.
- comfit.plot.plot_subplots_matplotlib.plot_subplots_matplotlib(number_of_rows, number_of_columns)
Create a figure with a grid of subplots.
- Return type:
Tuple
[Figure
,Axes
]
Parameters
- number_of_rowsint
Number of rows in the subplot grid.
- number_of_columnsint
Number of columns in the subplot grid.
Returns
- Tuple[plt.Figure, plt.Axes]
Figure object and array of Axes objects representing the subplots.
- comfit.plot.plot_subplots_plotly.plot_subplots_plotly(number_of_rows, number_of_columns)
Create a plotly figure with subplots.
- Return type:
Tuple
[Figure
,Dict
[str
,Any
]]
Parameters
- number_of_rowsint
Number of rows in the subplot grid.
- number_of_columnsint
Number of columns in the subplot grid.
Returns
- Tuple[go.Figure, Dict[str, Any]]
A tuple containing the Plotly figure and axes dictionary.
- comfit.plot.plot_surface_matplotlib.plot_surface_matplotlib(self, **kwargs)
Plot the surface of the given field.
- Return type:
Axes
Parameters
- selfBaseSystem
A BaseSystem (or derived) instance.
- **kwargsAny
- fieldndarray
3D array containing the field values
- valuefloat
Isosurface value
- axmatplotlib.axes.Axes, optional
Axes to plot on. Defaults to current axes.
- alphafloat, optional
Transparency value. Defaults to 0.5.
- colorstr, optional
Surface color. Defaults to ‘b’.
Returns
- matplotlib.axes.Axes
The axes containing the surface plot.
- comfit.plot.plot_vector_field_in_plane_both_plot_libs.plot_vector_field_in_plane_both_plot_libs(self, vector_field, position=None, normal_vector=None, spacing=None, **kwargs)
Plot a vector field on a plane in 3D space.
Creates a visualization of a vector field where it intersects with a plane defined by a point and a normal vector.
- Return type:
Tuple
[Any
,Any
]
Parameters
- selfBaseSystem
A BaseSystem (or derived) instance.
- vector_fieldnp.ndarray
The vector field to plot. Shape must be (1,xRes,yRes,zRes), (2,xRes,yRes,zRes), or (3,xRes,yRes,zRes).
- positionnp.ndarray, optional
Point through which the plane passes. Defaults to system midpoint.
- normal_vectornp.ndarray, optional
Normal vector defining the plane orientation. Defaults to [1,1,1].
- spacingint, optional
Spacing between vectors in the plot. Defaults to max(xRes//20,1).
- **kwargsAny
Additional keyword arguments for plot customization. See https://comfitlib.com/Plotting/.
Returns
- Tuple[Any, Any]
Figure and axes objects from the plotting library.
Raises
- Exception
If the system is not 3D or if the vector field has invalid dimensions.
- comfit.plot.plot_vector_field_matplotlib.plot_vector_field_matplotlib(self, vector_field, **kwargs)
Plot the vector field using matplotlib.
- Return type:
Tuple
[Figure
,Axes
]
Parameters
- selfBaseSystem
A BaseSystem (or derived) instance.
- vector_fieldnp.ndarray
Array containing the components of the vector field
- **kwargsAny
spacing : int, optional. The spacing for the quiver plot which defaults to self.xRes//20. Additional keyword arguments for plot customization, see https://comfitlib.com/Plotting/
Returns
- tuple[matplotlib.figure.Figure, matplotlib.axes.Axes]
Figure and axes containing the plot
Raises
- Exception
If an invalid field is provided to the plot_vector_field function
- comfit.plot.plot_vector_field_plotly.plot_vector_field_plotly(self, vector_field, **kwargs)
Plot the vector field using Plotly.
- Return type:
Tuple
[Figure
,dict
]
Parameters
- selfBaseSystem
A BaseSystem (or derived) instance.
- vector_fieldnp.ndarray
Array containing the vector field components. Shape depends on dimensionality.
- **kwargsAny
spacing : int, optional. The spacing for the quiver plot. Defaults to max(self.xRes//20, 1). Additional keyword arguments for plot customization, see https://comfitlib.com/Plotting/
Returns
- Tuple[go.Figure, dict]
The figure containing the plot and the axes dictionary containing plot properties.
Raises
- Exception
If an invalid field is provided to the plot_vector_field function.