Skip to contents

Creates a heatmap (tile plot) of indicator values. It can plot longitudinal data (date-based) or seasonal/categorical data (factor-based) depending on the input provided to the x argument.

Usage

plot_heatmap(
  data,
  x = "monyear",
  y_var = "state",
  fill = "value",
  title = NULL,
  legend_title = "Value",
  palette = c("viridis", "diverging", "sequential")
)

Arguments

data

A data frame, typically from get_hmis() or a summarized version.

x

Column for x-axis. Default "monyear". If "monyear" is used, it is automatically parsed to a Date. If a factor (like "month") is provided, the function automatically switches to a discrete scale.

y_var

Column for y-axis. Default "state".

fill

Column for fill color. Default "value".

title

Plot title. Default auto-generated.

legend_title

Legend title. Default "Value".

palette

One of "viridis", "diverging", or "sequential". Default "viridis".

Value

A ggplot object.

Examples

if (FALSE) { # \dontrun{
# Standard Longitudinal View (uses scale_x_date)
malaria <- get_hmis("Number of blood smears examined for Malaria",
  from = "Apr 2017", to = "Mar 2020"
)
plot_heatmap(malaria)

# Seasonal View (uses scale_x_discrete)
# Assumes 'month' is a factor (Jan-Dec) and 'cal_year' is a column
plot_heatmap(nmr_heat_norm, x = "month", y_var = "cal_year", fill = "nmr_norm")
} # }