-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathREADME.Rmd
More file actions
97 lines (66 loc) · 2.52 KB
/
Copy pathREADME.Rmd
File metadata and controls
97 lines (66 loc) · 2.52 KB
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
87
88
89
90
91
92
93
94
95
96
97
---
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%",
fig.width = 6,
fig.height = 3.7,
dpi = 300
)
```
# onsvplot <img src="man/figures/logo.png" align="right" height="139"/>
<!-- badges: start -->
[](https://github.com/pabsantos/onsvplot/actions/workflows/R-CMD-check.yaml)
[](https://CRAN.R-project.org/package=onsvplot)
[](https://lifecycle.r-lib.org/articles/stages.html#stable)
<!-- badges: end -->
The goal of `onsvplot` is to provide ggplot theme and color elements to help create graphics in the style of the [National Observatory for Road Safety](https://www.onsv.org.br/).
## Overview
This package provides two main functions and a palette of colors:
- `theme_onsv()`: Apply the ONSV theme to a ggplot object;
- `scale_discrete_onsv()`: Apply the ONSV color palette to a ggplot object;
- `onsv_palette`: A data object which provides the full palette of colors, including its hex codes.
## Installation
You can install the development version of `onsvplot` like so:
``` r
remotes::install_github("pabsantos/onsvplot")
```
Or the CRAN version:
``` r
# install.packages("onsvplot")
```
## Example
This is a basic example which shows you how to apply the functions included in this package. First, a basic ggplot graphics:
```{r example-1}
library(onsvplot)
library(ggplot2)
plot1 <-
ggplot(data = iris, aes(x = Sepal.Length, y = Sepal.Width, color = Species)) +
geom_point()
plot1
```
Then, apply `theme_onsv()` to change the theme of the plot and `scale_discrete_onsv()` to change the colors:
```{r example-2}
theme_set(theme_onsv())
plot1 + scale_discrete_onsv()
```
If only one color is necessary in the plot, it is possible to use one of the colors included in the `onsv_palette` object;
```{r example-3}
str(onsv_palette)
```
applying directly to the `color` or `fill` of the `geom:`
```{r example-4}
ggplot(data = iris, aes(x = Sepal.Length, y = Sepal.Width)) +
geom_point(color = onsv_palette$yellow)
```
## Citation
If you want to cite this package, you can cite as:
```{r citation, echo=FALSE}
citation("onsvplot")
```
<img src="man/figures/onsv.png" align="left" width="400"/>