Skip to content

Commit

Permalink
Merge pull request #4 from noradno/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
einartornes authored Feb 27, 2023
2 parents a0f8b56 + 9b6fcf2 commit f656a6a
Show file tree
Hide file tree
Showing 27 changed files with 73 additions and 15 deletions.
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ Imports:
ggplot2,
grDevices,
jsonlite,
showtext,
sysfonts
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Generated by roxygen2: do not edit by hand

export(ggnorad)
export(norad_pal)
export(scale_color_norad)
export(scale_color_norad_c)
Expand Down
25 changes: 25 additions & 0 deletions R/ggnorad.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#' Wrapper function to load norad theme
#'
#'@param ... Additional arguments
#'@export
#'@name ggnorad

ggnorad <- function(...) {

showtext::showtext_auto()

sysfonts::font_add(family = "Arimo",
regular = "fonts/Arimo-Regular.ttf",
bold = "fonts/Arimo-Bold.ttf",
italic = "fonts/Arimo-Italic.ttf",
bolditalic = "fonts/Arimo-BoldItalic.ttf")
sysfonts::font_add(family = "EB Garamond",
regular = "fonts/EBGaramond-Regular.ttf",
bold = "fonts/EBGaramond-Bold.ttf",
italic = "fonts/EBGaramond-Italic.ttf",
bolditalic = "fonts/EBGaramond-BoldItalic.ttf")

ggplot2::update_geom_defaults("path", list(linewidth = 1))

ggplot2::theme_set(theme_norad())
}
8 changes: 3 additions & 5 deletions R/style_functions.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@

#' Function for using Norad's theme in ggplot2 graphics
#'
#'@export
#'@name theme_norad
sysfonts::font_add_google(name = "Arimo")
sysfonts::font_add_google(name = "EB Garamond")

ggplot2::update_geom_defaults("path", list(linewidth = 1))

theme_norad <- function() {
sans <- "Arimo"
Expand All @@ -21,7 +19,7 @@ theme_norad <- function() {
plot.title.position = "plot",
plot.title = ggplot2::element_text(
family = serif,
size = 16,
size = 20,
face = "bold",
hjust = 0),
plot.subtitle = ggplot2::element_text(
Expand Down
9 changes: 7 additions & 2 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,15 @@ Norads colour palette and plot style for creating ggplot2 graphics.
library(ggplot2)
library(noradplot)
ggnorad()
ggplot(mpg, aes(displ, hwy, color = class)) +
geom_point() +
theme_norad() +
scale_color_norad()
scale_color_norad() +
labs(title = "This is the title",
subtitle = "This is the slightly longer subtitle",
caption = "This is the caption")
```

## Credits
Expand Down
27 changes: 19 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,39 @@

<!-- README.md is generated from README.Rmd. Please edit that file -->

# noradplot <img src="man/figures/sticker.png" align="right" width="120" />
# noradplot <img src="man/figures/sticker.png" align="right" width="120"/>

## Overview

Norads colour palette and plot style for creating ggplot2 graphics.

## Example
- Use `theme_norad()` to add norad style

- Use `scale_*` functions to add norad colour palette

## Examples

``` r

library(ggplot2)
library(noradplot)

ggnorad()

ggplot(mpg, aes(displ, hwy, color = class)) +
geom_point() +
theme_norad() +
scale_color_norad()
scale_color_norad() +
labs(title = "This is the title",
subtitle = "This is the slightly longer subtitle",
caption = "This is the caption")
```

![](man/figures/README-example-1.png)<!-- -->

Credits: Based on Simon Jackson’s blog post: Creating corporate colour
palettes for ggplot2, BBC BBC Visual and Data Journalism cookbook for R
graphics: <https://bbc.github.io/rcookbook/> and Meghan Halls blog post
Creating Custom colour palettes for ggplot2:
## Credits

Based on Simon Jackson’s blog post: Creating corporate colour palettes
for ggplot2, BBC BBC Visual and Data Journalism cookbook for R graphics:
<https://bbc.github.io/rcookbook/> and Meghan Halls blog post Creating
Custom colour palettes for ggplot2:
<https://meghan.rbind.io/blog/2022-10-11-creating-custom-color-palettes-with-ggplot2/>
Binary file added fonts/Arimo-Bold.ttf
Binary file not shown.
Binary file added fonts/Arimo-BoldItalic.ttf
Binary file not shown.
Binary file added fonts/Arimo-Italic.ttf
Binary file not shown.
Binary file added fonts/Arimo-Medium.ttf
Binary file not shown.
Binary file added fonts/Arimo-MediumItalic.ttf
Binary file not shown.
Binary file added fonts/Arimo-Regular.ttf
Binary file not shown.
Binary file added fonts/Arimo-SemiBold.ttf
Binary file not shown.
Binary file added fonts/Arimo-SemiBoldItalic.ttf
Binary file not shown.
Binary file added fonts/EBGaramond-Bold.ttf
Binary file not shown.
Binary file added fonts/EBGaramond-BoldItalic.ttf
Binary file not shown.
Binary file added fonts/EBGaramond-ExtraBold.ttf
Binary file not shown.
Binary file added fonts/EBGaramond-ExtraBoldItalic.ttf
Binary file not shown.
Binary file added fonts/EBGaramond-Italic.ttf
Binary file not shown.
Binary file added fonts/EBGaramond-Medium.ttf
Binary file not shown.
Binary file added fonts/EBGaramond-MediumItalic.ttf
Binary file not shown.
Binary file added fonts/EBGaramond-Regular.ttf
Binary file not shown.
Binary file added fonts/EBGaramond-SemiBold.ttf
Binary file not shown.
Binary file added fonts/EBGaramond-SemiBoldItalic.ttf
Binary file not shown.
Binary file modified man/figures/README-example-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions man/ggnorad.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/theme_norad.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f656a6a

Please sign in to comment.