tdcpy.plot package#
Submodules#
tdcpy.plot.discretization_animation module#
Set of functions for animation of discretization#
- tdcpy.plot.discretization_animation.discretization_animation(tds, discretization, s0=0j, **kwargs)#
Creates discretization animation
- Parameters:
discretization (iterable) – iterable of discretization degrees to animate over
s0 (complex, optional) – point discretization is done around, default 0j
**kwargs –
- discretization_idealint, optional
this discretization is assumed to be ‘correct’ and always present in animation, set None to turn off, default None
- xlimtuple, optional
x axis limits, default None
- ylimtuple, optional
y axis limits, default None
- intervalint, optional
time in ms between updates
- Returns:
ani – python Animation object, use plt.show() to see
- Return type:
animation
Notes
if this function does not suit you, copy and rewrite this
if you want to save animation, use ani.save(…) method of returned Animation object
Examples
>>> from tdcpy.ddae import DDAE >>> from tdcpy.plot.discretization_animation import discretization_animation >>> import numpy as np >>> E = np.array([[1, 0], [0, 0]]) >>> A = np.zeros((2,2,2)) >>> A[:,:,0] = np.array([[0, 1], [-2, -3]]) >>> A[:,:,1] = np.array([[0, 0], [0, -1]]) >>> hA = np.array([0.0, 1.0]) >>> tds = DDAE(E=E,A=A, hA=hA) >>> ani = discretization_animation(tds, discretization=range(2, 100), discretization_ideal=50) >>> # to show the animation, use plt.show()
tdcpy.plot.eigenvalues module#
Set of ploting eigenvalue plotting functions#
Mainly to provide similar functionality like the original TDS-CONTROl function:
https://gitlab.kuleuven.be/u0011378/tds-control/-/blob/main/tds-control/code/tds_eigenplot.m
- tdcpy.plot.eigenvalues.complex_scatter_axplot(roots, ax, *args, **kwargs)#
Plots non-empty complex numbers, x: Re(z), y: Im(z)
- Parameters:
roots (npt.NDArray) – array of complex numbers to visualize
ax (Axes) – matplotlib.axes.Axes object to plot to
*args – see matplotlib .scatter function
**kwargs – see matplotlib .scatter function
- Return type:
None
Notes
if roots is empty, does nothing
if ax is None, creates new figure and axes
uses matplotlib scatter function internally
x axis is real part, y axis is imaginary part
Examples
>>> import numpy as np >>> import matplotlib.pyplot as plt >>> from tdcpy.plot.eigenvalues import complex_scatter_axplot >>> roots = np.array([1+2j, -1-1j, 0+0j, 3+0j]) >>> fig, ax = plt.subplots() >>> complex_scatter_axplot(roots, ax, c='r', marker='x') >>> plt.show()
- tdcpy.plot.eigenvalues.eigen_plot(roots, ax=None, **kwargs)#
Plots eigenvalues in complex plane
- Parameters:
roots (npt.NDArray) – array of complex eigenvalues to plot
ax (Axes, optional) – matplotlib.axes.Axes object to plot to, default None
**kwargs – tol (float): tolerance for assuming Re(root) ~ 0, default 1e-10
- Returns:
ax – matplotlib.axes.Axes object containing the plot
- Return type:
Axes
Notes
if ax is None, creates new figure and axes
plots horizontal and vertical lines at 0
colors eigenvalues based on their real part:
red for Re(root) > tol
blue for |Re(root)| <= tol
green for Re(root) < -tol
Examples
>>> import numpy as np >>> import matplotlib.pyplot as plt >>> from tdcpy.plot.eigenvalues import eigen_plot >>> roots = np.array([1+2j, -1-1j, 0+0j, 3+0j]) >>> ax = eigen_plot(roots) >>> plt.show()