ANALYSIS TOOL BOX

Visualizations

PlotCard

Create a clean, card-style visualization for a single KPI or metric.

visualizationchartsplottinggraphs

Introduction

Sometimes the entire point of a chart is a single number — daily admissions, a conversion rate, this cycle's signal intercept count — and wrapping it in axes and gridlines only distracts from it. PlotCard renders exactly that single value as a clean, dashboard-style KPI card: one large number or text value with an optional descriptive label underneath, with full control over typography and color so it drops straight into an executive report or dashboard.

Teaching Note

KPI cards are essential for:

  • Healthcare: Displaying current hospital occupancy rates or daily admissions.
  • Epidemiology: Highlighting the total number of active cases or vaccination milestones.
  • Intelligence Analysis: Showcasing the number of high-priority signal intercepts in a cycle.
  • Data Science: Displaying top-level model metrics like R-squared or AUC.
  • Finance: Highlighting total revenue or profit margin for a specific period.
  • Operations: Displaying current system uptime or number of processed units.
  • Marketing: Showcasing total conversion count or average customer acquisition cost.
  • Public Health: Highlighting the current air quality index (AQI) for a specific city.

Parameters

ParameterTypeDefaultDescription
valuerequiredstr or int or floatThe primary data point to be displayed prominently in the center of the card.
value_labelstrNoneA descriptive label displayed below the primary value (e.g., 'Total Active Cases'). Defaults to None.
value_font_colorstr'#262626'The hex color code or name for the primary value text. Defaults to '#262626'.
value_font_sizeint30The font size for the primary value text in points. Defaults to 30.
value_font_familystr'Arial'The font family name for the primary value (e.g., 'Arial', 'Roboto'). Defaults to 'Arial'.
value_font_weightstr'bold'The font weight for the primary value (e.g., 'normal', 'bold', 'light'). Defaults to 'bold'.
value_label_font_colorstr'#595959'The hex color code or name for the secondary label text. Defaults to '#595959'.
value_label_font_sizeint14The font size for the secondary label text in points. Defaults to 14.
value_label_font_familystr'Arial'The font family name for the secondary label. Defaults to 'Arial'.
value_label_font_weightstr'normal'The font weight for the secondary label (e.g., 'normal', 'bold'). Defaults to 'normal'.
figure_sizetuple(3, 2)The dimensions of the output figure as a (width, height) tuple in inches. Defaults to (3, 2).
filepath_to_save_plotstrNoneThe local path (ending in .png or .jpg) where the card should be exported. If None, the file is not saved. Defaults to None.

Returns

None — the function displays the card using matplotlib and optionally saves it to disk with a transparent background.

Example

python
from analysistoolbox.visualizations import PlotCard

# Healthcare: displaying daily patient admissions
PlotCard(
    value=142,
    value_label="Daily Admissions",
    value_font_color="#b0170c",
    figure_size=(4, 2)
)