Visualization Workflows
Axis Labels
Build Plot Text
Readable charts need explicit labels for axes and titles.
Program
Play the script to choose which plot label is assembled.
axis_labels.R
axis_index <-
axis <- c("x", "y", "title")[axis_index]
text <- c(x = "Month", y = "Count", title = "Monthly Count")[[axis]]
label <- paste(axis, text, sep = "=")
cat(label, "\n", sep = "")
axis_index <-
axis <- c("x", "y", "title")[axis_index]
text <- c(x = "Month", y = "Count", title = "Monthly Count")[[axis]]
label <- paste(axis, text, sep = "=")
cat(label, "\n", sep = "")
axis_index <-
axis <- c("x", "y", "title")[axis_index]
text <- c(x = "Month", y = "Count", title = "Monthly Count")[[axis]]
label <- paste(axis, text, sep = "=")
cat(label, "\n", sep = "")
axis role
A short key can represent the x-axis, y-axis, or chart title.
named text
Named vectors let code retrieve the matching display text.
label string
The final string is what a plotting call would pass as metadata.