README.md

nudz.styles

Lukáš ‘hejtmy’ Hejtmánek 15/08/2020

R styles for easy NUDZ like coloring of your presentations and posters using ggplot.

Description

The main functions you will need to style your ggplots are scale_color_nudz and scale_fill_nudz. The main arguments allow you to specify what type of palette you want (see below), if you need discrete or continuous scaling and should the order of the colors be reversed. If you opt in for base plot package, you may use the nudz_palette command to produce your own palettes.

I have a slight issue with the yellow color, as it is literaly invisible on white backgroud. So I recommend using some more reflective background fill if you opt for thhe main palette, or just use a different one :)

Beware that the main palette only contains 5 values and the other ones even less. So not the best option for exploratory analyses of XY groups :)

Installation

Installation can be easilly done with devtools.

devtools::install_github("nudz/nudz.styles")

Usage

Discrete scales

plt <- ggplot(iris, aes(Sepal.Width, Sepal.Length, color = Species)) +
    geom_point(size = 4)
plt + scale_color_nudz() + ggtitle("Main NUDZ palette")

plt + scale_color_nudz(reversed = TRUE) + ggtitle("Main reversed NUDZ palette")

plt + scale_color_nudz(n_colors = c(1,3,4)) + ggtitle("Main NUDZ palette with selected colors")

Continuous scales

plt <- ggplot(iris, aes(Sepal.Width, Sepal.Length, color = Sepal.Width)) + 
  geom_point()
plt + scale_color_nudz(discrete = FALSE) + ggtitle("Main continuous NUDZ palette")

plt + scale_color_nudz(discrete = FALSE, n_colors = c(1,4)) + 
  ggtitle("Main continuous NUDZ palette with selected colors")

Base plots

Base plots are a little more troublesome as you need to do a biut of pallete preprocessing, especially for the continous values, but it can be done if you are more versed in base plotting than in ggplot.

pal <- nudz_palette()
pal <- pal(length(unique(iris$Species)))
plot(iris$Sepal.Width, iris$Sepal.Length, pch=19, col = pal[iris$Species])
legend("topright", col=pal, pch=19, 
       title = "Petal Length", legend=levels(iris$Species))

pal <- nudz_palette(n_colors = c(3,4), discrete=FALSE)
petal_cols <- (iris$Petal.Length-min(iris$Petal.Length))*10 # standardizing to whole numbers 
pal <- pal(max(petal_cols))
plot(iris$Sepal.Width, iris$Sepal.Length, pch=19, col = pal[petal_cols])
legend("topright", col=c(pal[1], pal[length(pal)]), pch=19, 
       title = "Petal Length", legend=range(iris$Petal.Length))

All palettes

show_palette(nudz_palette(palette = "main"))

show_palette(nudz_palette(palette = "main", discrete = FALSE))

show_palette(nudz_palette(palette = "grey_and_blue"))

show_palette(nudz_palette(palette = "grey_and_blue", discrete = FALSE))

show_palette(nudz_palette(palette = "red_and_blue"))

show_palette(nudz_palette(palette = "red_and_blue", discrete = FALSE))

show_palette(nudz_palette(palette = "black_and_white"))

show_palette(nudz_palette(palette = "black_and_white", discrete = FALSE))



NUDZ/nudz.styles documentation built on Feb. 6, 2021, 12:24 a.m.