Plots (dsptoolbox.plots)¶
Plots¶
This module contains plotting templates that use matplotlib and seaborn for styling.
general_matrix_plot()
general_plot()
general_subplots_line()
show()
- dsptoolbox.plots.general_matrix_plot(matrix, range_x=None, range_y=None, range_z: float | None = None, xlabel: str | None = None, ylabel: str | None = None, zlabel: str | None = None, xlog: bool = False, ylog: bool = False, colorbar: bool = True, cmap: str = 'magma', lower_origin: bool = True) tuple[Figure, Axes]¶
Generic plot template for a matrix’s heatmap.
- Parameters:
- matrixNDArray[np.float64]
Matrix with data to plot.
- range_xarray-like, optional
Range to show for x axis. Default: None.
- range_yarray-like, optional
Range to show for y axis. Default: None.
- range_zfloat, optional
Dynamic range to show. Default: None.
- xlabelstr, optional
Label for x axis. Default: None.
- ylabelstr, optional
Label for y axis. Default: None.
- zlabelstr, optional
Label for z axis. Default: None.
- xlogbool, optional
Show x axis as logarithmic. Default: False.
- ylogbool, optional
Show y axis as logarithmic. Default: False.
- colorbarbool, optional
When True, a colorbar for zaxis is shown. Default: True.
- cmapstr, optional
Type of colormap to use from matplotlib. See https://matplotlib.org/stable/tutorials/colors/colormaps.html. Default: ‘magma’.
- lower_originbool, optional
When True, the origin of the vertical axis of the matrix is put below. Default: True.
- Returns:
- fig, ax
- dsptoolbox.plots.general_plot(x: ndarray[tuple[Any, ...], dtype[_ScalarT]] | None, matrix: ndarray[tuple[Any, ...], dtype[_ScalarT]], range_x=None, range_y=None, log_x: bool = True, labels=None, xlabel: str = 'Frequency / Hz', ylabel: str | None = None, info_box: str | None = None, tight_layout: bool = True) tuple[Figure, Axes]¶
Generic plot template.
- Parameters:
- xarray-like
Vector for x axis. Pass None to generate automatically.
- matrixNDArray[np.float64]
Matrix with data to plot.
- range_xarray-like, optional
Range to show for x axis. Default: None.
- range_yarray-like, optional
Range to show for y axis. Default: None.
- log_xbool, optional
Show x axis as logarithmic. Default: True.
- labelslist or str, optional
Labels for the drawn lines as list of strings. Default: None.
- xlabelstr, optional
Label for x axis. Default: None.
- ylabelstr, optional
Label for y axis. Default: None.
- info_boxstr, optional
String containing extra information to be shown in a info box on the plot. Default: None.
- tight_layout: bool, optional
When True, tight layout is activated. Default: True.
- Returns:
- fig, ax
- dsptoolbox.plots.general_plot_two_axes(x1: ndarray[tuple[Any, ...], dtype[_ScalarT]] | None, matrix1: ndarray[tuple[Any, ...], dtype[_ScalarT]], x2: ndarray[tuple[Any, ...], dtype[_ScalarT]] | None, matrix2: ndarray[tuple[Any, ...], dtype[_ScalarT]], range_x=None, range_y1=None, range_y2=None, log_x: bool = True, labels1=None, labels2=None, xlabel: str = 'Frequency / Hz', y1label: str | None = None, y2label: str | None = None, y1_linestyle: str | None = None, y2_linestyle: str | None = None, y1_alpha: float = 1.0, y2_alpha: float = 1.0, info_box: str | None = None, tight_layout: bool = True) tuple[Figure, list[Axes]]¶
Plot template for two y-axis with the same x-axis.
- Parameters:
- x1array-like
Vector for x axis. Pass None to generate automatically.
- matrix1NDArray[np.float64]
Matrix with data to plot. The first dimension is expected to match the x data.
- x2array-like
Vector for x axis. Pass None to generate automatically.
- matrix2NDArray[np.float64]
Matrix with data to plot. The first dimension is expected to match the x data.
- range_xarray-like, optional
Range to show for x axis. Default: None.
- range_y1array-like, optional
Range to show for y axis. Default: None.
- range_y2array-like, optional
Range to show for second y axis. Default: None.
- log_xbool, optional
Show x axis as logarithmic. Default: True.
- labels1list or str, optional
Labels for the drawn lines as list of strings. Default: None.
- labels2list or str, optional
Labels for the drawn lines as list of strings. Default: None.
- xlabelstr, optional
Label for x axis. Default: None.
- y1labelstr, optional
Label for y axis. Default: None.
- y2labelstr, optional
Label for y axis. Default: None.
- y1_linestylestr, None, optional
Line style for first axis. Default: None.
- y2_linestylestr, None, optional
Line style for second axis. Default: None.
- y1_alphafloat, optional
Alpha value for first axis. Default: 1.
- y2_alphafloat, optional
Alpha value for second axis. Default: 1.
- info_boxstr, optional
String containing extra information to be shown in a info box on the plot. Default: None.
- tight_layout: bool, optional
When True, tight layout is activated. Default: True.
- Returns:
- fig, [ax, ax2]
- dsptoolbox.plots.general_subplots_line(x: ndarray[tuple[Any, ...], dtype[_ScalarT]] | None, matrix: ndarray[tuple[Any, ...], dtype[_ScalarT]], column: bool = True, sharex: bool = True, sharey: bool = False, log_x: bool = False, xlabels=None, ylabels=None, range_x=None, range_y=None) tuple[Figure, list[Axes]]¶
Generic plot template with subplots in one column or row.
- Parameters:
- xarray-like
Vector for x axis. The same x vector is used for all subplots. Pass None to generate automatically.
- matrixNDArray[np.float64]
Matrix with data to plot.
- columnbool, optional
When True, the subplots are organized in one column. Default: True.
- sharexbool, optional
When True, all subplots share the same values for the x axis. Default: True.
- shareybool, optional
When True, all subplots share the same values for the y axis. Default: False.
- log_xbool, optional
Show x axis as logarithmic. Default: False.
- xlabelsarray_like, optional
Labels for x axis. Default: None.
- ylabelsarray_like, optional
Labels for y axis. Default: None.
- range_xarray-like, optional
Range to show for x axis. Default: None.
- range_yarray-like, optional
Range to show for y axis. Default: None.
- Returns:
- fig, ax
- dsptoolbox.plots.show()¶
Show created plots by using this wrapper around matplotlib’s show.