Display a complete or sparse age-year table as a heatmap, surface or contour. Buttons change the metric, display type and value scale; an optional model selector compares models using the same ranges within each metric.
Usage
plot_matrix(
data,
metric = NULL,
frame = NULL,
type = c("heatmap", "surface", "contour"),
signed = FALSE,
y = ~age,
ylab = "Age",
y_labels = NULL
)Arguments
- data
A data frame with numeric
year,ageandestcolumns. Optionalunit,definition,notesandis_projcolumns enrich hover text.- metric
Optional one-sided formula selecting a metric column.
- frame
Optional one-sided formula selecting a model column. Factor levels determine the initial model and selector order.
- type
Initial display:
"heatmap","surface"or"contour".- signed
Use symmetric orange-white-navy ranges centred on zero and disable the log control? Default
FALSEpreserves ordinary matrix plots.- y
One-sided formula selecting the vertical coordinate, default
~age. Character/factor coordinates use ordered positions with each model's own labels, suitable for unique M state blocks.- ylab
Vertical-axis label, default
"Age". A named character vector can supply a different label for each metric.- y_labels
Optional one-sided formula selecting display labels for the vertical coordinates, useful for model-specific state blocks.
Details
Linear shows original estimates, including zero. Log displays
log10 estimates; nonpositive values are gaps. Hover text always shows
original values and units. Ranges are shared across models separately for
each metric. All models of a metric must use the same units.
Colours use the built-in tam_cols() ramp from low to high values.
Colour-ramp titles place units on a second line; axis labels remain on one line.
Missing cells remain missing. Surface and contour rendering interpolates
only for display and does not create additional source estimates.
Examples
d <- expand.grid(year = 2000:2005, age = 1:5)
d$est <- exp(.1 * (d$year - 2000) - .3 * d$age)
plot_matrix(d)