Plots#

Based on ISARICDraw.py: ISARICResearch/VERTEX

polyflame.plots.cumulative_bar(data: DataFrame, **kwargs: Unpack[PlotInfo]) Figure#

Pivot the DataFrame to get cumulative sums for each stack_group at each timepoint Ensure the ‘timepoint’ column is sorted or create a complete range if necessary

polyflame.plots.lighten(hex_color: str, factor: float = 0.6) str#

Lightens a hex color by a fraction

polyflame.plots.plot(kwargs: DataPlotInfo) Figure | DataFrame#

Generic plotting function for PolyFLAME

Unlike polyflame.plot_unpacked(), this function takes a single dictionary as a parameter. This is used together with adapter functions from data sources, such as the FHIRflat adapter.

polyflame.plots.plot_unpacked(data: DataFrame, type: Literal['pyramid', 'upset', 'proportion'] | None, **kwargs: Unpack[PlotInfo]) Figure | DataFrame#

Generic plotting function dispatcher, unpacked version

Parameters:
  • data – Data to plot

  • type – Type of plot, one of pyramid, upset or proportion

  • **kwargs – Additional plot parameters

polyflame.plots.proportion(data: DataFrame, **kwargs: Unpack[PlotInfo]) Figure#

Proportions plot by label

                Frequency of signs and symptoms

      cough  ████████████████████████████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
sore throat  ████████████████████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
      fever  ███████████████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒

██ yes  ▒▒ no
polyflame.plots.pyramid(data: DataFrame, **kwargs: Unpack[PlotInfo]) Figure#

Dual-stack pyramid plot, used for age pyramid

↓ Age                Female       |          Male
                                  |
91-95                             |██
86-90                       █▒▒▒▒▒|▒▒▒▒▒█
81-85                      ▒▒▒▒▒▒▒|▒▒▒▒▒▒▒▒██
76-80               ██▒▒▒▒▒▒▒▒▒▒▒▒|▒▒▒▒▒████

██ death  ▒▒ discharged
polyflame.plots.require_columns(data: DataFrame, required_columns: list[str], column_mappings: dict[str, str] | None = None) None#

Requires a set of columns to be present, raises a ValueError otherwise

polyflame.plots.upset(data, **kwargs: Unpack[PlotInfo]) Figure#

UpSet plot

            Intersection size

40           █
30           █  █
20           █  █     █
10           █  █  █  █     █
0            █  █  █  █  █  █  █

cough        ●        ●     ●  ●
                      |     |  |
sore throat     ●     ●  ●  |  ●
                         |  |  |
headache           ●     ●  ●  ●