scale_colour_dft | R Documentation |
Function to use custom DfT palettes for line colours in ggplot charts
scale_colour_dft(palette = "electric.brights", gradient = FALSE, ...)
palette |
Named DfT palette to use in line colours. Defaults to "electric.brights" |
gradient |
Boolean response whether to use gradient palette instead of standard palettes. Defaults to false. |
... |
Other arguments to pass to extract gradients function |
## Simple line plot using default palette
library(ggplot2)
df <- economics_long[economics_long$variable %in% c("psavert", "uempmed"), ]
# plot
ggplot(df, aes(x=date)) +
geom_line(aes(y=value, col=variable), size = 1) +
scale_colour_dft()+
theme(axis.text.x = element_text(angle = 90, vjust=0.5, size = 8)) # turn off minor grid
## More complex line plot using full range of colours in palette
library(ggplot2)
df <- data.frame(supp=rep(c("VC1", "OJ", "VC2", "OJ2"), each=3),
dose=rep(c("D0.5", "D1", "D2"), 4),
len=c(6.8, 15, 33, 4.2, 10, 29.5, 3.6, 11, 21, 2, 8, 16))
# plot
ggplot(df, aes(x=dose, y=len, colour=supp, group = supp)) +
geom_line(size = 1) +
scale_colour_dft(palette = "electric.brights")+
theme(axis.text.x = element_text(angle = 90, vjust=0.5, size = 8)) # turn off minor grid
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.