-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
77 lines (57 loc) · 2.05 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
---
output:
md_document:
variant: markdown_github
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-figs/"
)
```
# ggaqua
Contains a simple theme for ggplot2, `theme_aqua()`, that is based on SLU Aqua report style. The theme builds on `ggplot2::theme_bw()`.
Installing:
```{r, eval=FALSE}
# install.packages("devtools")
devtools::install_github("maxlindmark/ggaqua")
# slu aqua colors
if (!require(remotes)) {
install.packages(remotes)
}
remotes::install_github("kagervall/SLUcolors")
```
Below is an example plot of a time series of catch of Pike in the large lakes in Sweden (a dataset that is built in here called "pike").
```{r, echo=FALSE}
set.seed(1)
```
```{r example, fig.width=5.5, fig.height=3.6, fig.retina=2}
library(ggplot2)
library(ggaqua)
library(SLUcolors)
pal <- SLUpalette(1)
d <- data.frame(year = 1999:2019,
response = rnorm(mean = 200, sd = 10, n = length(1999:2019)))
# a basic slu-aqua themed plot
ggplot(d, aes(year, response)) +
geom_bar(stat = "identity", width = 0.6, fill = pal[1]) +
scale_x_continuous(expand = c(0, 0), breaks = scales::pretty_breaks(n = 6)) +
scale_y_continuous(expand = c(0, 0), breaks = scales::pretty_breaks(n = 5)) +
theme_aqua() +
labs(y = "Landningar (ton)", x = "")
# save!
#ggsave("Fig_1.png", plot = p1, dpi = 300, width = 8, height = 8, units = "cm")
```
Another common application of this theme is for the annual report "Fiskbarometern". Here's an example of how to make a figure for that report with the corresponding palette.
```{r}
# a basic"fiskbarometern" style plot
pal <- c("#56B4E9", "#009E73", "#F0E442", "#0072B2", "#E69F00", "#D55E00")
ggplot(d, aes(year, response)) +
geom_bar(stat = "identity", width = 0.6, fill = pal[1]) +
scale_x_continuous(expand = c(0, 0), breaks = scales::pretty_breaks(n = 6)) +
scale_y_continuous(expand = c(0, 0), breaks = scales::pretty_breaks(n = 5)) +
theme_aqua() +
labs(y = "Landningar (ton)", x = "")
```