The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

Using with {ggplot2}

Install from CRAN using:

install.packages("PrettyCols")

Or install the development version using:

remotes::install_github("nrennie/PrettyCols")

Then load into R:

library(PrettyCols)

Set up a simple data frame to use for an example plot:

library(ggplot2)
df <- data.frame(
  type = c("A", "B", "C"),
  value = c(1, 2, 3)
)

To change the fill or colour for discrete variables:

ggplot(
  data = df,
  mapping = aes(x = type, y = value, fill = type)
) +
  geom_col() +
  scale_fill_pretty_d(palette = "Blues")

ggplot(
  data = df,
  mapping = aes(x = type, y = value, colour = type)
) +
  geom_col(linewidth = 2, fill = "white") +
  scale_colour_pretty_d(palette = "Blues")

To change the fill or colour for continuous variables:

ggplot(
  data = df,
  mapping = aes(x = type, y = value, fill = value)
) +
  geom_col() +
  scale_fill_pretty_c(palette = "Purples")

ggplot(
  data = df,
  mapping = aes(x = type, y = value, colour = value)
) +
  geom_col(linewidth = 2, fill = "white") +
  scale_colour_pretty_c(palette = "Purples", direction = -1)

To change the fill or colour for continuous (diverging) variables (using diverging palettes only):

ggplot(
  data = df,
  mapping = aes(x = type, y = value, fill = value)
) +
  geom_col() +
  scale_fill_pretty_div(palette = "PurpleYellows", midpoint = 2)

ggplot(
  data = df,
  mapping = aes(x = type, y = value, colour = value)
) +
  geom_col(linewidth = 2, fill = "white") +
  scale_colour_pretty_div(palette = "PurpleYellows", midpoint = 2)

To change the legend title:

ggplot(
  data = df,
  mapping = aes(x = type, y = value, fill = value)
) +
  geom_col() +
  scale_fill_pretty_c(palette = "Purples", name = "My New Title") +
  theme(legend.title = element_text(colour = "blue"))

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.