tuesday.core.plotting¶
A sub-package for typical plotting routines such as power spectra.
- tuesday.core.plotting.plot_1d_power_spectrum_k(power_spectrum: SphericalPS, *, ax: Axes | None = None, title: str | None = None, xlabel: str | None = None, ylabel: str | None = None, color: list | None = None, log: list[bool] | None = False, fontsize: float | None = 16, legend: str | None = None, smooth: float | bool = False, legend_kwargs: dict | None = None) tuple[Figure, Axes][source]¶
Plot 1D power spectrum vs wave mode.
- Parameters:
power_spectrum (SphericalPS) – Instance of the SphericalPS class.
ax (plt.Axes, optional) – Axes object to plot on. If None, a new axes is created.
title (str, optional) – Title of the plot.
xlabel (str, optional) – Label for the x-axis.
ylabel (str, optional) – Label for the y-axis.
color (str, optional) – Color of the PS line in the plot.
log (list[bool], optional) – List of booleans to set the x and y axes to log scale.
fontsize (float, optional) – Font size for the plot labels.
legend (str, optional) – Legend label for the PS.
smooth (float, optional) – Standard deviation for Gaussian smoothing. If True, uses a standard deviation of 1.
legend_kwargs (dict, optional) – Keyword arguments for the legend.
- tuesday.core.plotting.plot_1d_power_spectrum_z(power_spectra: list[SphericalPS], at_k: float, *, ax: Axes | None = None, title: str | None = None, xlabel: str | None = 'Redshift', ylabel: str | None = None, color: list | None = 'C0', log: list[bool] | None = False, fontsize: float | None = 16, legend: str | None = None, smooth: float | bool = False, legend_kwargs: dict | None = None) tuple[Figure, Axes][source]¶
Plot 1D power spectra as a function of redshift at a given scale.
- Parameters:
power_spectrum (list[SphericalPS]) – List of instances of the SphericalPS class.
at_k (float) – If provided, plots the 1D power spectrum at a specific k value. The k value is assumed to be in the same unit as the k in the SphericalPS instance wavemodes.
ax (plt.Axes, optional) – Axes object to plot on. If None, a new axes is created.
title (str, optional) – Title of the plot.
xlabel (str, optional) – Label for the x-axis.
ylabel (str, optional) – Label for the y-axis.
color (str, optional) – Color of the PS line in the plot.
log (list[bool], optional) – List of booleans to set the x and y axes to log scale.
fontsize (float, optional) – Font size for the plot labels.
legend (str, optional) – Legend label for the PS.
smooth (float, optional) – Standard deviation for Gaussian smoothing. If True, uses a standard deviation of 1.
legend_kwargs (dict, optional) – Keyword arguments for the legend.
- tuesday.core.plotting.plot_2d_power_spectrum(power_spectrum: CylindricalPS, *, ax: Axes | None = None, title: str | None = None, xlabel: str | None = None, ylabel: str | None = None, clabel: str | None = None, cmap: str | None = 'viridis', fontsize: float | None = 16, vmin: float | None = None, vmax: float | None = None, log: list[bool] | None = False, smooth: float | bool = False, cbar: bool | None = True) tuple[Figure, Axes][source]¶
Plot a 2D power spectrum.
- Parameters:
power_spectrum (CylindricalPS) – Instance of the CylindricalPS class.
axs (plt.Axes | list[plt.Axes], optional) – Axes object(s) to plot on. If None, new axes are created.
title (str, optional) – Title(s) of the plot.
xlabel (str, optional) – Label for the x-axis.
ylabel (str, optional) – Label for the y-axis.
clabel (str, optional) – Label for the colorbar.
cmap (str, optional) – Colormap for the plot.
fontsize (float, optional) – Font size for the plot labels.
vmin (float, optional) – Minimum value for the color scale.
vmax (float, optional) – Maximum value for the color scale.
log (list[bool], optional) – List of booleans to set the kperp, kpar, and PS axes to log scale.
smooth (float, optional) – Standard deviation for Gaussian smoothing. Default is False, if True, uses a standard deviation of 1.
- tuesday.core.plotting.plot_coeval_slice(coeval: Quantity, box_length: Quantity, *, fontsize: float | None = 16, title: str | None = None, xlabel: str | None = None, ylabel: str | None = None, clabel: str | None = None, cmap: str = 'viridis', logx: bool = False, logy: bool = False, logc: bool = False, idx: int = 0, vmin: float | None = None, vmax: float | None = None, ax: Axes | None = None, smooth: bool | float = False, transform2slice: Callable | None = None, v_x: Quantity | None = None, v_y: Quantity | None = None, quiver_label: str | bool = False, quiver_kwargs: dict | None = None, quiver_label_kwargs: dict | None = None, quiver_decimate_factor: int = 1) Axes[source]¶
Plot a slice from a coeval of shape (Nx, Ny, N redshifts).
- Parameters:
coeval (un.Quantity) – The coeval data cube with shape (Nx, Ny, N redshifts).
box_length (un.Quantity) – The length of the box.
title (str, optional) – The title of the plot.
xlabel (str, optional) – The label for the x-axis.
ylabel (str, optional) – The label for the y-axis.
clabel (str, optional) – The label for the colorbar.
cmap (str, optional) – The colormap to use for the plot.
logx (bool, optional) – Whether to use a logarithmic scale for the x-axis.
logy (bool, optional) – Whether to use a logarithmic scale for the y-axis.
logc (bool, optional) – Whether to use a logarithmic scale for the colorbar.
idx (int, optional) – The index of the slice to plot along the z-axis. Default is 0.
vmin (float, optional) – The minimum value for the color scale.
vmax (float, optional) – The maximum value for the color scale.
ax (plt.Axes, optional) – The axes to plot on. If None, a new figure and axes will be created.
smooth (bool | float, optional) – Whether to apply Gaussian smoothing to the coeval data. If True, a default sigma of 1.0 will be used. If a float, it will be used as the sigma for the Gaussian filter.
transform2slice (Callable, optional) – A function to transform the coeval data into a slice. If None, the default slicing function will be used.
v_x (un.Quantity, optional) – The x-component of the velocity field to plot as a vector field on top of the slice plot. This is a 2D array with shape (Nx, Ny).
v_y (un.Quantity, optional) – The y-component of the velocity field to plot as a vector field on top of the slice plot. This is a 2D array with shape (Nx, Ny).
quiver_label (str | bool, optional) – The label for the quiver plot that appears on the top right corner right outside of the plot area. If True, a default label will be put, assuming the velocity is being plotted. If False, no label will be added.
quiver_kwargs (dict, optional) – Additional keyword arguments for the quiver plot, such as arrow color, width, etc. See matplotlib.pyplot.quiver for more details.
quiver_label_kwargs (dict, optional) – Additional keyword arguments for the quiver label, such as color, angle, etc. See matplotlib.pyplot.quiverkey for more details.
quiver_decimate_factor (int, optional) – The factor by which to decimate the vector field for plotting. This is useful for reducing the number of arrows in the quiver plot to avoid cluttering the plot. Default is 1 (no decimation).
- Returns:
plt.Axes – The axes with the coeval slice plot.
- tuesday.core.plotting.plot_pdf(box: Quantity, *, fontsize: float | None = 16, title: str | None = None, xlabel: str | None = None, ylabel: str | None = None, logx: bool = False, ax: Axes | None = None, smooth: bool | float = False, hist_kwargs) Axes[source]¶
Plot a pxiel distribution function (PDF) of the box.
- Parameters:
box (un.Quantity) – The box data to plot.
fontsize (float, optional) – The font size for the plot.
title (str, optional) – The title of the plot.
xlabel (str, optional) – The label for the x-axis.
ylabel (str, optional) – The label for the y-axis.
logx (bool, optional) – Whether to use a logarithmic scale for the x-axis.
ax (plt.Axes, optional) – The axes to plot on. If None, a new figure and axes will be created.
smooth (bool | float, optional) – Whether to apply Gaussian smoothing to the box data. If True, a default sigma of 1.0 will be used. If a float, it will be used as the sigma for the Gaussian filter.
- Returns:
plt.Axes – The axes with the PDF plot.
- tuesday.core.plotting.plot_power_spectrum(power_spectrum: SphericalPS | CylindricalPS | list[SphericalPS], *, ax: Axes | list[Axes] | None = None, title: str | None = None, xlabel: str | None = None, ylabel: str | None = None, clabel: str | None = None, at_k: float | int | None = None, cmap: str | None = 'viridis', color: list | None = None, fontsize: float | None = 16, vmin: float | None = None, vmax: float | None = None, logx: bool | None = False, logy: bool | None = False, logc: bool | None = False, cbar: bool | None = True, legend: str | None = None, smooth: float | bool = False, legend_kwargs: dict | None = None) tuple[Figure, Axes][source]¶
Plot a power spectrum.
- Parameters:
power_spectrum (CylindricalPS | SphericalPS | list[SphericalPS]) – Instance of the CylindricalPS class, or instance or list of instances of the or SphericalPS class.
ax (plt.Axes | list[plt.Axes], optional) – Axes object(s) to plot on. If None, new axes are created.
title (str, optional) – Title of the plot.
xlabel (str, optional) – Label for the x-axis.
ylabel (str, optional) – Label for the y-axis.
clabel (str, optional) – Label for the colorbar.
at_k (float | int, optional) – If provided, plots the 1D power spectrum at a specific k value. If int, it is interpreted as the index of the k value. If float, it is interpreted as the k value itself in the same unit as the k in the SphericalPS instance wavemodes.
cmap (str, optional) – Colormap for the plot.
colors (list, optional) – List of colors for each line in the plot.
fontsize (float, optional) – Font size for the plot labels.
vmin (float, optional) – Minimum value for the color scale.
vmax (float, optional) – Maximum value for the color scale.
logx (bool, optional) – Whether to set the x-axis to log scale.
logy (bool, optional) – Whether to set the y-axis to log scale.
logc (bool, optional) – Whether to set the color-axis to log scale.
legend (str, optional) – Legend label for the 1D PS.
smooth (bool or float, optional) – Standard deviation for Gaussian smoothing. If True, uses a standard deviation of 1.
legend_kwargs (dict, optional) – Keyword arguments for the legend on the 1D PS plot.
- tuesday.core.plotting.plot_redshift_slice(lightcone: Quantity, box_length: Quantity, redshift: ndarray | Quantity, *, fontsize: float | None = 16, title: str | None = None, xlabel: str | None = None, ylabel: str | None = None, clabel: str | None = None, cmap: str = 'eor', logx: bool = False, logy: bool = False, logc: bool = False, zmin: float | None = None, zmax: float | None = None, vmin: float | None = None, vmax: float | None = None, ax: Axes | None = None, smooth: bool | float = False, transform2slice: Callable | None = None) Axes[source]¶
Plot a slice from a lightcone of shape (N_x, N_y, N_redshifts).
- Parameters:
lightcone (un.Quantity) – The lightcone data to plot with shape (N_x, N_y, N_redshifts).
box_length (un.Quantity) – The length of the box.
redshift (np.ndarray | un.Quantity) – The redshift values corresponding to the lightcone.
title (str, optional) – The title of the plot.
xlabel (str, optional) – The label for the x-axis.
ylabel (str, optional) – The label for the y-axis.
clabel (str, optional) – The label for the colorbar.
cmap (str, optional) – The colormap to use for the plot.
logx (bool, optional) – Whether to use a logarithmic scale for the x-axis.
logy (bool, optional) – Whether to use a logarithmic scale for the y-axis.
logc (bool, optional) – Whether to use a logarithmic scale for the colorbar.
zmin (float, optional) – The minimum redshift of the lightcone.
zmax (float, optional) – The maximum redshift of the lightcone.
vmin (float, optional) – The minimum value for the color scale.
vmax (float, optional) – The maximum value for the color scale.
ax (plt.Axes, optional) – The axes to plot on. If None, a new figure and axes will be created.
smooth (bool | float, optional) – Whether to apply Gaussian smoothing to the lightcone data. If True, a default sigma of 1.0 will be used. If a float, it will be used as the sigma for the Gaussian filter.