PyPlanAnalysis.plots

Matplotlib plotting helpers for DVH/LVH curves and 2-D/3-D DLVH maps.

PyPlanAnalysis.plots

Matplotlib plotting helpers for DVH/LVH curves and 2-D/3-D DLVH maps.

plot_cumulative_histogram(curves, title, xlabel='Dose [Gy(RBE)]', ylabel='Volume fraction', dpi=150)[source]

Plot cumulative DVH or LVH curves for multiple structures.

Parameters:
  • curves (dict {structure_name: (edges, cum_volume_fraction)})

  • title (plot title string)

  • xlabel (x-axis label)

  • ylabel (y-axis label)

  • dpi (figure DPI)

Return type:

Figure

Returns:

matplotlib Figure

plot_dvh_comparison(curves_per_model, structure_name, dpi=150)[source]

Overlay DVH curves for multiple dose types on one structure.

Parameters:
  • curves_per_model (dict {model_label: (edges, cum)}) –

    e.g. {“Physical”: (…), “RBE1.1”: (…),

    ”McNamara”: (…)}

  • structure_name (used in the plot title)

  • dpi (int)

Return type:

Figure

Returns:

matplotlib Figure

plot_dlvh_2d(H, dose_edges, let_edges, structure_name, dpi=150)[source]

2-D dose-LET volume histogram (DLVH) as a colourmap.

Parameters:
  • H (2-D array (dose_bins × let_bins), volume fractions)

  • dose_edges (dose bin edges [Gy(RBE)])

  • let_edges (LET bin edges [keV/µm])

  • structure_name (used in title)

  • dpi (figure DPI)

Return type:

Figure

Returns:

matplotlib Figure

plot_dlvh_3d(H_pct, d_edges, l_edges, structure_name, dpi=150)[source]

3D surface plot of the cumulative DLVH. Z axis = volume [%], X = dose, Y = LET.

save_figures_to_pdf(figures, path, dpi=150)[source]

Save a list of matplotlib Figures to a multi-page PDF.

Parameters:
  • figures (list of (title_str, Figure) or just [Figure, ...])

  • path (output PDF path)

  • dpi (int)

save_figure(fig, path, dpi=150)[source]

Save a single figure and close it.

Parameters:
  • fig (Figure)

  • path (str | Path)

  • dpi (int)