Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/DoctorBJones/BJ
Package with BJ's functions and themes
https://github.com/DoctorBJones/BJ
Last synced: 8 days ago
JSON representation
Package with BJ's functions and themes
- Host: GitHub
- URL: https://github.com/DoctorBJones/BJ
- Owner: DoctorBJones
- License: gpl-3.0
- Created: 2021-12-23T10:16:02.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-01-03T20:28:14.000Z (almost 3 years ago)
- Last Synced: 2024-08-13T07:11:31.407Z (4 months ago)
- Language: R
- Size: 32.2 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
- jimsghstars - DoctorBJones/BJ - Package with BJ's functions and themes (R)
README
# BJ Package
This package contains a suite of helper functions. Currently it contains ggplot themes, colours and palettes to more easily make pretty visualisations.
## Installation
You can install the development version of BJ from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("DoctorBJones/BJ")
```## Examples
There are currently six functions: three for colours and three for themes.
The colour functions allow you to:
* select individual colours by name using bj_cols(),
* select palettes of colour using either scale_colour_bj() or scale_fill_bj().``` r
library(BJ)
library(ggplot2)ggplot(mpg, aes(manufacturer)) +
geom_bar(fill = bj_cols("light orange"))ggplot(mpg, aes(class, fill = class)) +
geom_bar() +
scale_fill_bj()
```
You can also interpolate the palettes for use with continuous variables and reverse the colours.
```r
ggplot(mpg, aes(displ, cty, colour = cty)) +
geom_point() +
scale_color_bj(palette = "orange gradient", discrete = FALSE)ggplot(mpg, aes(displ, cty, colour = cty)) +
geom_point() +
scale_color_bj(palette = "orange gradient", discrete = FALSE, reverse = TRUE)
```
The palettes are also ordered, so if you have fewer than 5 levels, it will automatically use the first x colours (or the last x if you use `reverse = TRUE`)
``` r
ggplot(mpg, aes(drv, fill = drv)) +
geom_bar() +
scale_fill_bj()
```
There are also three basic ggplot themes. One is for numeric data and the other two are for vertical and horizontal representations of categorical data, such as bar charts.
``` r
ggplot(mpg, aes(class, fill = class)) +
geom_bar() +
scale_fill_bj() +
theme_bj_vbar()ggplot(mpg, aes(y = drv, fill = drv)) +
geom_bar() +
scale_fill_bj() +
theme_bj_hbar()ggplot(mpg, aes(displ, cty, colour = cty)) +
geom_point() +
scale_color_bj(palette = "green gradient", discrete = FALSE) +
theme_bj_numeric()
```
Lastly, there is a function to easily create gauge plots.
``` r
gauge_plot(0.22, text_colour = "black")
gauge_plot(0.58, text_colour = bj_cols("text grey"))
gauge_plot(0.12, reverse = TRUE)
```
The package also imports the ['Nanum Gothic'](https://fonts.google.com/specimen/Nanum+Gothic) font from Google fonts for use in all themes.