pysdkit.plot#
Created on Sat Mar 4 21:31:05 2024 @author: Whenxuan Wang @email: wwhenxuan@gmail.com Some auxiliary function modules for data visualization in the PySDKit library
Created on Sat Mar 4 11:59:21 2024 @author: Whenxuan Wang @email: wwhenxuan@gmail.com |
|
Created on 2024/6/2 21:12 @author: Whenxuan Wang @email: wwhenxuan@gmail.com |
|
Created on 2025/02/02 16:47:10 @author: Whenxuan Wang @email: wwhenxuan@gmail.com |
|
Created on 2025/02/11 21:42:45 @author: Whenxuan Wang @email: wwhenxuan@gmail.com |
plot.plot_imfs#
Created on Sat Mar 4 11:59:21 2024 @author: Whenxuan Wang @email: wwhenxuan@gmail.com
可视化图像的函数需要再专门去写几个 就不同可视化信号的放在一起了
对分解后的频谱进行可视化
- pysdkit.plot._plot_imfs.plot_IMFs(signal: ndarray, IMFs: ndarray, max_imfs: int | None = -1, view: str | None = '2d', colors: List | None = None, save_figure: bool | None = False, return_figure: bool | None = False, dpi: int | None = 64, spine_width: float = 2, labelpad: float = 10, save_name: str | None = None) Figure | None[source]#
Visualizes the numpy array of intrinsic mode functions derived from the decomposition of a signal. Can be used as a generic interface for plotting.
You can choose to visualize on a 2D plane or in 3D space.
The 2D plane visualization is more intuitive, while the 3D visualization can better reflect the size relationship between the decomposed modes.
- Parameters:
signal – The input original signal
IMFs – The intrinsic mode functions obtained after signal decomposition
max_imfs – The number of decomposition modes to be plotted
view – The view of the figure, choice [“2d”, “3d”]
colors – List of color strings for plotting
save_figure – Whether to save the figure as an image
return_figure – Whether to return the figure object
dpi – The resolution of the saved image
spine_width – The width of the visible axes spines
labelpad – Controls the filling distance of the y-axis coordinate
save_name – The name of the saved image file
- Returns:
The figure object for the plot
plot.fourier_spectra#
Created on 2024/6/2 21:12 @author: Whenxuan Wang @email: wwhenxuan@gmail.com
- pysdkit.plot._fourier_spectra.plot_IMFs_amplitude_spectra(IMFs: ndarray, norm: bool | None = True, smooth: str | None = None, colors: List | None = None, figsize: Tuple | None = None, save_figure: bool = False, return_figure: bool = False, dpi: int = 500, fontsize: float = 14, save_name: str | None = None) figure[source]#
Plot amplitude spectra of Intrinsic Mode Functions (IMFs) obtained from signal decomposition
- Parameters:
IMFs – Input Intrinsic Mode Functions
norm – Whether to normalize the Fourier transform results
smooth – Whether to smooth the amplitude spectra, and the method to use
colors – List of colors to use for plotting
figsize – Size of the figure (default is (12, 5))
save_figure – Whether to save the plotted figure
return_figure – Whether to return the figure object
dpi – Resolution of the created figure (default is 500)
fontsize – Font size for the labels and title (default is 14)
save_name – Name to save the figure
- Returns:
Figure object (if return_figure is True)
plot.plot_images#
Created on 2025/02/02 16:47:10 @author: Whenxuan Wang @email: wwhenxuan@gmail.com
- pysdkit.plot._plot_images.plot_grayscale_image(img: ndarray, figsize: Tuple | None = (5, 5), dpi: int | None = 100, cmap: str | None = 'coolwarm') Tuple[Figure, Axes][source]#
Visualize a 2D grayscale image.
- Parameters:
img – The input 2D ndarray matrix from numpy.
figsize – The size of the figure.
dpi – The resolution used, default is 100.
cmap – The colormap used.
- Returns:
Figure and Axes from matplotlib.
- pysdkit.plot._plot_images.plot_grayscale_spectrum(img: ndarray, figsize: Tuple | None = (5, 5), dpi: int | None = 100, cmap: str | None = 'coolwarm') Tuple[Figure, Axes][source]#
Plot the spectrum distribution of a 2D grayscale image.
- Parameters:
img – The input 2D ndarray matrix from numpy.
figsize – The size of the figure.
dpi – The resolution used, default is 100.
cmap – The colormap used.
- Returns:
Figure and Axes from matplotlib.
- pysdkit.plot._plot_images.plot_images(img: ndarray, spectrum: bool | None = False, dpi: int | None = 128, cmap: str | None = 'coolwarm', colorbar: bool | None = False, save_figure: bool | None = False, save_name: str | None = None, return_figure: bool | None = False) Figure | None[source]#
Visualize univariate and multivariate 2D images. It is a packaged general interface. The input data img is a univariate image [height, width] or a multivariate image [n_vars, height, width] The spectrum variable controls whether to visualize the time domain The colorbar variable controls whether to add a color bar
- Parameters:
img – The input images,which shape are [height, width]或[n_vars, height, width]
spectrum – bool, Whether to draw the spectrum image of fast Fourier transform at the same time
dpi – The resolution at which the image is drawn
cmap – The colormap to use, defaults is colorwarm
colorbar – bool, whether to add a color bar to the drawn image
save_figure – Whether to save the figure as an image
save_name – The name of the saved image file
return_figure – Whether to return the figure object
- Returns:
The plotting Figure from matplotlib
plot.plot_signal#
Created on 2025/02/11 21:42:45 @author: Whenxuan Wang @email: wwhenxuan@gmail.com
- pysdkit.plot._plot_signal.plot_signal(time: array, signal: array, spectrum: bool | None = False, color: str = 'royalblue', save: bool = False, dpi: int = 128, fontsize: int = 12) figure[source]#
Plot and optionally save an amplitude modulated (AM) signal with time on the x-axis and amplitude on the y-axis.
- Parameters:
time – Array of time points corresponding to the signal.
signal – Array containing the signal data to be plotted.
spectrum – bool, Whether to draw the spectrum signal of fast Fourier transform at the same time
color – Color of the plot line.
save – Boolean flag to indicate whether the plot should be saved to a file.
dpi – Dots per inch (resolution) of the figure, if saved.
fontsize – Font size of the axis labels.
- Returns:
The figure object containing the plot.