Description Usage Arguments Value Examples
scale_gov
provides a means to easily use the
gov_cols
palette in charts. It applies the palette in order as an
unnamed vector.
1 |
type |
sets whether the scale applies to (line) |
... |
additional arguments to be supplied to the underlying ggplot2
|
Will not return anything of itself, but when used in conjuntion
with ggplot
and (e.g.) geom_col
from the
package ggplot2
, will apply a colour scale to a plot.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | library(ggplot2)
library(govstyle)
library(dplyr)
df <- data.frame(
group = c("apple", "apple", "apple", "pear", "pear", "pear"),
year = c(2009, 2010, 2011, 2009, 2010, 2011),
price = c(35, 37, 36, 24, 25, 28))
# Column chart
ggplot(df, aes(x = year, y = price, fill = group)) +
geom_col(position = "dodge") +
theme_gov() +
scale_gov("fill")
# Line chart
ggplot(df, aes(x = year, y = price, colour = group)) +
geom_line(size = 2) +
theme_gov() +
scale_gov("colour")
# Point chart, with filled points (black outline)
ggplot(df, aes(x = year, y = price, colour = group)) +
geom_line() +
geom_point(shape = 21, size = 4, stroke = 1, fill = "#ffffff") +
theme_gov() +
scale_gov("colour") +
ylim(0,40)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.