pycsa.plotting.plotter¶
Contains the classes and functions for single-cell plots.
Functions
|
Bar plot of absolute error values without a y-axis break. |
|
Bar plot of errors. |
|
Function to generate error bar plots with a split in the middle, e.g., when space in limited on a presentation slide or poster. |
Classes
|
A figure object class to plot physical and spectral panels. |
|
Helper class for 3D plots |
- class pycsa.plotting.plotter.fig_obj(fig, nhi, nhj, cbar=True, set_label=True)¶
A figure object class to plot physical and spectral panels.
- __init__(fig, nhi, nhj, cbar=True, set_label=True)¶
Initializes the figure object and the methods fill the axes.
- Parameters:
fig (
matplotlib.figure.Figureinstance) – matplotlib figurenhi (int) – number of harmonics in the first horizontal direction
nhj (int) – number of harmonics in the second horizontal direction
cbar (bool, optional) – user-defined colorbar, by default True
set_label (bool, optional) – toggle axis labels, by default True
- phys_panel(axs, data, title='', extent=None, xlabel='', ylabel='', v_extent=None)¶
Plots a physical depiction of the input data.
- Parameters:
axs (
plt.Axes) – matplotlib figure axisdata (array-like) – 2D image data
title (str, optional) – panel title, by default “”
extent (list, optional) – [x0,x1,y0,y1], by default “”
xlabel (str, optional) – x-axis label, by default “”
ylabel (str, optional) – y-axis label, by default “”
v_extent (list, optional) – [h0,h1]; vertical extent of the data, by default None
- Returns:
matplotlib figure axis
- Return type:
plt.Axes
- freq_panel(axs, ampls, nhi=None, nhj=None, title='Power spectrum', v_extent=None, show_edge=False)¶
Plots the spectrum in a dense truncated spectral space.
- Parameters:
axs (
plt.Axes) – matplotlib figure axisampls (array-like) – 2D (abs.) spectral data
nhi (int, optional) – number of harmonics in the first horizontal direction, by default None
nhj (int, optional) – number of harmonics in the second horizontal direction, by default None
title (str, optional) – user-defined panel title, by default “Power spectrum”
v_extent (list, optional) – [h0,h1]; vertical extent of the data, by default None
show_edge (bool, optional) – toggle the cell-edge outline on the color mesh, by default False
- Returns:
matplotlib figure axis
- Return type:
plt.Axes
- fft_freq_panel(axs, ampls, kks, lls, title='FFT power spectrum', interval=20, typ='imag')¶
Plots the spectrum in the full spectral space.
- Parameters:
axs (
plt.Axes) – matplotlib figure axisampls (array-like) – 2D (abs.) spectral data
kks (list) – list of first horizontal wavenumbers
lls (list) – list of second horizontal wavenumbers
title (str, optional) – user-defined panel title, by default “FFT power spectrum”
interval (int, optional) – half-width (in wavenumber indices) of the spectral window cropped around the center before plotting, by default 20
typ ({"imag", "real"}, optional) – spectral representation to plot; “imag” crops a symmetric window about the spectral center, “real” keeps the positive first-wavenumber half, by default “imag”
- Returns:
matplotlib figure axis
- Return type:
plt.Axes
- pycsa.plotting.plotter.error_bar_plot(idx_name, pmf_diff, params, comparison=None, title='', gen_title=False, output_fig=False, fn='../output/error_plot.pdf', ylim=[-100, 100], fs=(10.0, 6.0), ylabel='', fontsize=8, show_grid=True)¶
Bar plot of errors.
- Parameters:
idx_name (list) – labels of the error plots, e.g., cell index
pmf_diff (list) – list containing the errors. Same size as idx_name.
params (
pycsa.config.params.params) – user parameter classcomparison (list, optional) – a second error list to be compared to pmf_diff. Same size as pmf_diff, by default None
title (str, optional) – user-defined panel title, by default “”
gen_title (bool, optional) – automatically generate panel title from params, by default False
output_fig (bool, optional) – toggle writing figure output, by default False
fn (str, optional) – path to write output figure, by default “../output/error_plot.pdf”
ylim (list, optional) – extent of the error bar plot, by default [-100,100]
fs (tuple, optional) – figure size, by default (10.0,6.0)
ylabel (str, optional) – y-axis label, by default “”
fontsize (int, optional) – by default 8
show_grid (bool, optional) – toggles grid in output, by default True
- pycsa.plotting.plotter.error_bar_split_plot(errs, lbls, bs, ts, ts_ticks, color, fs=(3.5, 3.5), title='', output_fig=False, fn='output/errors.pdf')¶
Function to generate error bar plots with a split in the middle, e.g., when space in limited on a presentation slide or poster.
- Parameters:
errs (list) – list of error values, one per bar (rounded to 2 d.p. internally)
lbls (list) – bar labels, used as the x-axis tick labels. Same size as errs.
bs (float) – upper limit of the lower (bottom) axis; the y-axis break occurs here
ts (list) –
[t0, t1]y-limits of the upper (top) axis above the breakts_ticks (list) – explicit y-tick locations for the upper axis
color (color or list) – bar color(s) passed to
matplotlib.axes.Axes.bar()fs (tuple, optional) – figure size, by default (3.5, 3.5)
title (str, optional) – figure title, by default “”
output_fig (bool, optional) – toggle writing figure output, by default False
fn (str, optional) – path to write output figure, by default “output/errors.pdf”
- pycsa.plotting.plotter.error_bar_abs_plot(errs, lbls, fs=(3.5, 3.5), title='', output_fig=False, fn='output/errors.pdf', color=None, ylims=None, fontsize=10)¶
Bar plot of absolute error values without a y-axis break.
- Parameters:
errs (list) – list of error values, one per bar (rounded to 2 d.p. internally)
lbls (list) – bar labels, used as the x-axis tick labels. Same size as errs.
fs (tuple, optional) – figure size, by default (3.5, 3.5)
title (str, optional) – figure title, by default “”
output_fig (bool, optional) – toggle writing figure output, by default False
fn (str, optional) – path to write output figure, by default “output/errors.pdf”
color (color or list, optional) – bar color(s) passed to
matplotlib.axes.Axes.bar(), by default Noneylims (list, optional) –
[y0, y1]y-axis limits; left unset when None, by default Nonefontsize (int, optional) – title font size, by default 10
- class pycsa.plotting.plotter.plot_3d(cell, ele=5, azi=230, cpad=0.01)¶
Helper class for 3D plots
- __init__(cell, ele=5, azi=230, cpad=0.01)¶
- Parameters:
cell (
pycsa.data.cell.topo_cell) – instance of a cell objectele (int, optional) – elevation angle, by default 5
azi (int, optional) – azimuthal angle, by default 230
cpad (float, optional) – color bar padding, by default 0.01
- plot(Z, output_fig=True, output_fn='plot_3D', lbls=None, fs=(10, 10))¶
Does the plotting
- Parameters:
Z (array-like) – 2D elevation array
output_fig (bool, optional) – toggles output of figure, by default True
output_fn (str, optional) – output filename, by default “plot_3D”. The figure is always written to
./outputs/<output_fn>.pdf(the./outputs/directory and.pdfsuffix are hardcoded).lbls (list, optional) – list of axis labels containing
[x_label, y_label, z_label], by default Nonefs (tuple, optional) – figure size, by default (10,10)