-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
86 lines (62 loc) · 2.5 KB
/
README.Rmd
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# SPHSUgraphs
<!-- badges: start -->
[![AppVeyor build status](https://ci.appveyor.com/api/projects/status/github/andrewbaxter439/SPHSUgraphs?branch=master&svg=true)](https://ci.appveyor.com/project/andrewbaxter439/SPHSUgraphs)
[![R CMD Check](https://github.com/andrewbaxter439/SPHSUgraphs/workflows/R-CMD-check/badge.svg)](https://github.com/andrewbaxter439/SPHSUgraphs/actions)
<!-- badges: end -->
For applying Unit colour scales and other theme aesthetics to ggplot2 plots
## Installation
You can install the development version of SPHSUgraphs from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("andrewbaxter439/SPHSUgraphs")
```
## The Unit Palette
Use `sphsu_show_colours()` to show the range of named colours you can use:
```{r}
library(SPHSUgraphs)
sphsu_show_colours()
```
## Adding a palette
Colour and fill functions have four pre-installed palettes: \"main\", \"hot\", \"cool\" and \"mixed\". You can add a custom palette like so:
```{r}
sphsu_palettes$newname <- sphsu_cols("Cobalt", "Thistle", "Leaf")
```
You can then use this new palette name in calls of `scale_fill_sphsu` and `scale_colour_sphsu` (see below).
## Using in ggplot
Right now the main output of these functions is to apply colour and fill scales to your `ggplot2` graphics, by adding a `scale_` function at the end of your call.
Examples:
```{r}
ggplot(iris, aes(Sepal.Width, Sepal.Length, col = Species)) +
geom_point(size = 4) +
scale_colour_sphsu()
```
```{r}
ggplot(iris, aes(Sepal.Width, Sepal.Length, col = Sepal.Length)) +
geom_point(size = 4) +
scale_colour_sphsu("hot", discrete = FALSE)
```
```{r}
ggplot(iris, aes(Sepal.Width, Sepal.Length, col = Sepal.Length)) +
geom_point(size = 4) +
scale_colour_sphsu("cool", discrete = FALSE)
```
```{r}
ggplot(mpg, aes(manufacturer, fill = manufacturer)) +
geom_bar() +
theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
scale_fill_sphsu(palette = "mixed", guide = "none")
```
# Acknowledgements
This package was developed from the helpful walkthrough at [Simon Jackson\'s blogpost](https://drsimonj.svbtle.com/creating-corporate-colour-palettes-for-ggplot2) on creating colour palettes (Accessed 08/11/2019). With thanks to [@drsimonj](https://www.twitter.com/drsimonj)!