Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://pabsantos.github.io/onsvplot/
National Road Safety Observatory (ONSV) Style for 'ggplot2' Graphics
https://pabsantos.github.io/onsvplot/
Last synced: 3 days ago
JSON representation
National Road Safety Observatory (ONSV) Style for 'ggplot2' Graphics
- Host: GitHub
- URL: https://pabsantos.github.io/onsvplot/
- Owner: pabsantos
- License: other
- Created: 2023-07-14T19:57:03.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-11T17:09:46.000Z (11 months ago)
- Last Synced: 2024-10-13T14:54:05.747Z (about 1 month ago)
- Language: R
- Homepage: https://pabsantos.github.io/onsvplot/
- Size: 5.23 MB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
README
---
output: github_document
---```{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
[![R-CMD-check](https://github.com/pabsantos/onsvplot/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/pabsantos/onsvplot/actions/workflows/R-CMD-check.yaml)
[![CRAN status](https://www.r-pkg.org/badges/version/onsvplot)](https://CRAN.R-project.org/package=onsvplot)
[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)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")
```