Helper to add a bar image legend to plots
legend_bar(position, col, width_prop = 0.03, heigh_prop = 0.18,
title = "Legend", labels = c("Low", "High"), digits = 0,
labels_offset = 0.2, horizontal = FALSE, alpha = 1, border = NULL,
cex = NULL, inset = 0.05, insetx = NULL, insety = NULL)
(numeric or character) position of the bottom left corner of the legend. If numeric, x and y coordinates. If character, options are: "bottomright", "bottom", "bottomleft", "left", "topleft", "top", "topright", "right", or "center".
color palette. A vector of contiguous colors. It can be generated
using functions like purplow
(e.g., darkros(255)
).
width of bar legend represented as a proportion of the entire plotting width. Default = 0.03.
heigh of bar legend represented as a proportion of the entire plotting heigh. Default = 0.18.
legend title. Default = "Legend".
(numeric or character) labels for the legend. Default = c("Low", "High").
(numeric) number of decimal places to round numeric labels. Default = 0.
offset of labels from bar. Default = 0.2.
(logical) should the legend be horizontal. Default = FALSE.
(numeric) alpha level 0-1. Default = 1.
color for the border of the legend bar. The default, NULL, does not plot a border.
character expansion factor relative to current. Default = NULL.
inset distances from plot margins relative to plot region. Default = 0.05.
inset from x margins. The default, NULL, uses inset
.
inset from y margins. The default, NULL, uses inset
.
A bar legend for a plot.