This package is intended to be used for storing and accessing NMR color palettes in R, for easy integration in visualization and reporting.
At the moment, it contains three core functions. The first,
nmr_colors
, produces a named list of colors (or,
optionally) a contrasting set of colors. Use ?nmr_colors
to
see further documentation. The second, draw_palette
, is a
thin wrapper on nmr_colors
for drawing ggplot figures using
the palettes.
Then there are additional helper functions, including
scale_*
functions that integrate NMR palettes with
ggplot2
Calling nmr_colors
returns the color IDs and their hex
codes.
## B2 T1 G2 T3
## "#115B6B" "#FFFFCC" "#649429" "#6B5E0A"
Create graphics using above call to nmr_colors
with the
following code:
data.frame(hex = output) |>
ggplot(aes(fill = hex)) +
facet_wrap( ~ hex, ncol = 1) +
geom_rect(aes(xmin = 1, xmax = 2,
ymin = 1, ymax = 2)) +
lims(x=c(1,2),y=c(1,2)) +
scale_fill_manual(values = as.character(output),
guide = "none") +
theme(axis.text = element_blank(),
axis.ticks = element_blank(),
panel.grid = element_blank(),
panel.spacing = unit(-0.5, "lines"),
plot.margin = unit(c(0,-0.25,0,-0.25), "lines"),
strip.background = element_blank(),
strip.text = element_blank())
paletteNMR also contains scale_*
functions modeled on
those in the ggplot2
package for visualization.
data.frame(hex = output) |>
ggplot(aes(fill = hex)) +
facet_wrap( ~ hex, ncol = 1) +
geom_rect(aes(xmin = 1, xmax = 2,
ymin = 1, ymax = 2)) +
lims(x=c(1,2),y=c(1,2)) +
scale_nmr_fill_categorical(pal = "quad",
set = "F",
guide = "none") +
theme(axis.text = element_blank(),
axis.ticks = element_blank(),
panel.grid = element_blank(),
panel.spacing = unit(-0.5, "lines"),
plot.margin = unit(c(0,-0.25,0,-0.25), "lines"),
strip.background = element_blank(),
strip.text = element_blank())