├── .Rbuildignore ├── .github └── workflows │ └── r_cmd_check.yml ├── .gitignore ├── DESCRIPTION ├── LICENCE ├── LICENSE ├── NAMESPACE ├── R ├── 0tools.R ├── colours.R └── theme_fira.R ├── README.md ├── firatheme.Rproj ├── img ├── chick.png ├── firacols.png ├── firapalette.png ├── iris.png ├── ozone.png ├── plot.png └── title.svg ├── inst └── font │ ├── FiraSans-Bold.ttf │ ├── FiraSans-BoldItalic.ttf │ ├── FiraSans-Italic.ttf │ ├── FiraSans-Medium.ttf │ ├── FiraSans-MediumItalic.ttf │ ├── FiraSans-Regular.ttf │ └── OFL.txt └── man ├── firaCols.Rd ├── firaPalette.Rd ├── firaSave.Rd ├── scale_fira.Rd └── theme_fira.Rd /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^.*\.Rproj$ 2 | ^\.Rproj\.user$ 3 | ^.*.pdf 4 | ^img 5 | ^.travis.yml 6 | ^LICENSE$ 7 | ^.github 8 | -------------------------------------------------------------------------------- /.github/workflows/r_cmd_check.yml: -------------------------------------------------------------------------------- 1 | # For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag. 2 | # https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions 3 | on: 4 | push: 5 | branches: 6 | - master 7 | pull_request: 8 | branches: 9 | - master 10 | 11 | name: R-CMD-check 12 | 13 | jobs: 14 | R-CMD-check: 15 | runs-on: ${{ matrix.config.os }} 16 | 17 | name: ${{ matrix.config.os }} (${{ matrix.config.r }}) 18 | 19 | strategy: 20 | fail-fast: false 21 | matrix: 22 | config: 23 | - {os: windows-latest, r: 'release'} 24 | - {os: macOS-latest, r: 'release'} 25 | - {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} 26 | - {os: ubuntu-20.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} 27 | 28 | env: 29 | R_REMOTES_NO_ERRORS_FROM_WARNINGS: true 30 | RSPM: ${{ matrix.config.rspm }} 31 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 32 | 33 | steps: 34 | - uses: actions/checkout@v2 35 | 36 | - uses: r-lib/actions/setup-r@v1 37 | with: 38 | r-version: ${{ matrix.config.r }} 39 | 40 | - uses: r-lib/actions/setup-pandoc@v1 41 | 42 | - name: Query dependencies 43 | run: | 44 | install.packages('remotes') 45 | saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) 46 | writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") 47 | shell: Rscript {0} 48 | 49 | - name: Restore R package cache 50 | if: runner.os != 'Windows' 51 | uses: actions/cache@v2 52 | with: 53 | path: ${{ env.R_LIBS_USER }} 54 | key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} 55 | restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- 56 | 57 | - name: Install system dependencies 58 | if: runner.os == 'Linux' 59 | run: | 60 | while read -r cmd 61 | do 62 | eval sudo $cmd 63 | done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04"))') 64 | - name: Install dependencies 65 | run: | 66 | remotes::install_deps(dependencies = TRUE) 67 | remotes::install_cran("rcmdcheck") 68 | shell: Rscript {0} 69 | 70 | - name: Check 71 | env: 72 | _R_CHECK_CRAN_INCOMING_REMOTE_: false 73 | run: | 74 | options(crayon.enabled = TRUE) 75 | rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check") 76 | shell: Rscript {0} 77 | 78 | - name: Upload check results 79 | if: failure() 80 | uses: actions/upload-artifact@main 81 | with: 82 | name: ${{ runner.os }}-r${{ matrix.config.r }}-results 83 | path: check 84 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | .Ruserdata 5 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: firatheme 2 | Type: Package 3 | Title: A ggplot2 Theme using the Fira Sans Font 4 | Version: 0.2.4 5 | Author: Erik-Jan van Kesteren 6 | Maintainer: Erik-Jan van Kesteren 7 | Description: Make your graphs pretty with the Fira font, colours and prettified 8 | axes and labels. 9 | License: MIT + file LICENCE 10 | Encoding: UTF-8 11 | LazyData: true 12 | Imports: 13 | ggplot2, 14 | extrafont, 15 | grDevices 16 | RoxygenNote: 7.1.1 17 | -------------------------------------------------------------------------------- /LICENCE: -------------------------------------------------------------------------------- 1 | YEAR: 2018 2 | COPYRIGHT HOLDER: Erik-Jan van Kesteren 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Erik-Jan van Kesteren 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export(firaCols) 4 | export(firaPalette) 5 | export(firaSave) 6 | export(scale_color_fira) 7 | export(scale_colour_fira) 8 | export(scale_fill_fira) 9 | export(theme_fira) 10 | importFrom(grDevices,pdfFonts) 11 | -------------------------------------------------------------------------------- /R/0tools.R: -------------------------------------------------------------------------------- 1 | #' @importFrom grDevices pdfFonts 2 | .onAttach <- function(libname, pkgname) { 3 | ## Load all fonts 4 | extrafont::loadfonts(quiet = TRUE) 5 | if (.Platform$OS.type == "windows") { 6 | windowsFonts <- grDevices::windowsFonts 7 | extrafont::loadfonts("win", quiet = TRUE) 8 | } 9 | } 10 | 11 | setupFont <- function() { 12 | # Loadfonts 13 | if (!"Fira Sans" %in% extrafont::fonts()) { 14 | extrafont::ttf_import(paths = system.file("font", package = "firatheme")) 15 | } 16 | 17 | ## Load all fonts 18 | extrafont::loadfonts("pdf", quiet = TRUE) 19 | extrafont::loadfonts("postscript", quiet = TRUE) 20 | if (.Platform$OS.type == "windows") { 21 | extrafont::loadfonts("win", quiet = TRUE) 22 | } 23 | } 24 | 25 | fontsReady <- function() { 26 | if (.Platform$OS.type == "windows") { 27 | if ("Fira Sans" %in% grDevices::windowsFonts()) return(TRUE) 28 | } else { 29 | if ("Fira Sans" %in% extrafont::fonts()) return(TRUE) 30 | } 31 | return(FALSE) 32 | } 33 | 34 | setupGhostScript <- function() { 35 | # Setup ghostscript for pdf output 36 | if (.Platform$OS.type == "windows") { 37 | binpath <- "bin/gswin64c.exe" 38 | basepath <- "C:/Program Files/gs" 39 | gsdirs <- list.dirs(basepath, recursive = FALSE) 40 | matches <- regexpr("[0-9].[0-9]*$", gsdirs) 41 | potentials <- matches > 0 42 | nmatches <- sum(potentials) 43 | 44 | if (nmatches == 1) { 45 | # only one version is installed 46 | Sys.setenv(R_GSCMD = file.path(gsdirs[potentials], binpath)) 47 | } else if (nmatches > 1) { 48 | # find newest version 49 | versions <- numeric(nmatches) 50 | for (i in 1:nmatches) { 51 | m <- matches[potentials][i] 52 | mlen <- attr(matches, "match.length")[potentials][i] 53 | gsdir <- gsdirs[potentials][i] 54 | versions[i] <- as.numeric(gsub("\\.", "", substr(gsdir, m, m + mlen))) 55 | } 56 | Sys.setenv(R_GSCMD = file.path(gsdirs[potentials][which.max(versions)], 57 | binpath)) 58 | } else { 59 | stop("64-bit GhostScript could not be found. Install 64-bit GhostScript", 60 | " or run the following with the _correct_ location", 61 | " to the installed GhostScript Binary:\n Sys.setenv(R_GSCMD =", 62 | ' "C:/Program Files/gs/gs/bin/gswin64c.exe")') 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /R/colours.R: -------------------------------------------------------------------------------- 1 | #' Fira theme palette 2 | #' 3 | #' This function outputs n colours from the fira ggplot2 theme palette 4 | #' 5 | #' @param n the number of colours to output 6 | #' 7 | #' @seealso \code{\link{firaCols}} 8 | #' 9 | #' @export 10 | firaPalette <- function(n = 5) { 11 | if (n == 4) return(firaCols[c(1, 3, 4, 5)]) 12 | grDevices::colorRampPalette(firaCols, space = "Lab")(n) 13 | } 14 | 15 | #' Fira theme colours 16 | #' 17 | #' This is a vector with 5 colours to be used in palettes and other visual 18 | #' elements. 19 | #' 20 | #' @seealso \code{\link{firaPalette}} 21 | #' 22 | #' @export 23 | firaCols <- c("#3030a3", "#dd7373", "#499293", "#30602d", "#e2bd36") 24 | 25 | #' Fira discrete colour scales 26 | #' 27 | #' Colour scales belonging to the fira theme 28 | #' 29 | #' @inheritParams ggplot2::scale_colour_hue 30 | #' @param continuous whether the associated variable should be considered 31 | #' continuous. Typically used after "Error: Continuous value supplied to 32 | #' discrete scale" 33 | #' 34 | #' @seealso \code{\link{firaPalette}} 35 | #' 36 | #' @rdname scale_fira 37 | #' @export 38 | scale_fill_fira <- function(..., continuous = FALSE) { 39 | if (continuous) { 40 | pal <- grDevices::colorRampPalette(c(firaCols[1], firaCols[5]), 41 | space = "Lab") 42 | return(ggplot2::scale_fill_gradientn(..., colours = pal(256))) 43 | } 44 | ggplot2::discrete_scale("fill", paste0("fira"), firaPalette, ...) 45 | } 46 | 47 | 48 | #' @rdname scale_fira 49 | #' @export 50 | scale_colour_fira <- function(..., continuous = FALSE) { 51 | if (continuous) { 52 | pal <- grDevices::colorRampPalette(c(firaCols[1], firaCols[5]), 53 | space = "Lab") 54 | return(ggplot2::scale_colour_gradientn(..., colours = pal(256))) 55 | } 56 | ggplot2::discrete_scale("colour", paste0("fira"), firaPalette, ...) 57 | } 58 | 59 | #' @rdname scale_fira 60 | #' @export 61 | scale_color_fira <- scale_colour_fira 62 | -------------------------------------------------------------------------------- /R/theme_fira.R: -------------------------------------------------------------------------------- 1 | #' Fira theme 2 | #' 3 | #' This theme uses Mozilla's Fira Sans as its font. 4 | #' Save to pdf using \code{firaSave()}. 5 | #' 6 | #' @param family Change the font family. Defaults to Fira Sans 7 | #' 8 | #' @return ggplot theme 9 | #' 10 | #' @examples 11 | #' library(ggplot2) 12 | #' 13 | #' ggplot(mtcars, aes(x = mpg*0.43, y = wt*0.4535924, colour = factor(cyl))) + 14 | #' geom_point(size = 2) + 15 | #' labs(title = "Car weight vs efficiency", 16 | #' subtitle = "Using sensible metrics", 17 | #' x = "Efficiency (km/l)", 18 | #' y = "Weight (1000 kg)", 19 | #' colour = "Cylinders") + 20 | #' theme_fira() + 21 | #' scale_colour_fira() 22 | #' 23 | #' @seealso \code{\link{firaSave}} 24 | #' 25 | #' @export 26 | theme_fira <- function(family = "Fira Sans") { 27 | if (!fontsReady()) setupFont() 28 | ggplot2::`%+replace%`( 29 | ggplot2::theme_grey(base_size = 11.5, base_family = family), 30 | ggplot2::theme( 31 | # add padding to the plot 32 | plot.margin = grid::unit(rep(0.5, 4), "cm"), 33 | 34 | # remove the plot background and border 35 | plot.background = ggplot2::element_blank(), 36 | panel.background = ggplot2::element_blank(), 37 | panel.border = ggplot2::element_blank(), 38 | 39 | # make the legend and strip background transparent 40 | legend.background = ggplot2::element_rect(fill = "transparent", 41 | colour = NA), 42 | legend.key = ggplot2::element_rect(fill = "transparent",colour = NA), 43 | strip.background = ggplot2::element_rect(fill = "transparent", 44 | colour = NA), 45 | 46 | # add light, dotted major grid lines only 47 | panel.grid.major = ggplot2::element_line(linetype = "dotted", 48 | colour = "#454545", 49 | size = 0.3), 50 | panel.grid.minor = ggplot2::element_blank(), 51 | 52 | # remove the axis tick marks and hide axis lines 53 | axis.ticks = ggplot2::element_blank(), 54 | axis.line = ggplot2::element_line(color = "#454545", size = 0.3), 55 | 56 | # modify the bottom margins of the title and subtitle 57 | plot.title = ggplot2::element_text(size = 18, colour = "#454545", 58 | hjust = 0.5, 59 | margin = ggplot2::margin(b = 10)), 60 | plot.subtitle = ggplot2::element_text(size = 12, colour = "#454545", 61 | hjust = 0.5, 62 | margin = ggplot2::margin(b = 10)), 63 | 64 | # add padding to the caption 65 | plot.caption = ggplot2::element_text(size = 10, colour = "#454545", 66 | hjust = 1, 67 | margin = ggplot2::margin(t = 15)), 68 | 69 | # Adjust text size and axis title position 70 | axis.title = ggplot2::element_text(size = 13, colour = "#454545", 71 | hjust = 0.95), 72 | axis.text = ggplot2::element_text(size = 10, colour = "#212121"), 73 | legend.title = ggplot2::element_text(size = 12, colour = "#454545"), 74 | legend.text = ggplot2::element_text(size = 10, colour = "#454545"), 75 | strip.text = ggplot2::element_text(size = 12, colour = "#454545", 76 | margin = ggplot2::margin(10, 10, 77 | 10, 10, 78 | "pt")) 79 | ) 80 | ) 81 | } 82 | 83 | 84 | #' Save plots that use the fira theme 85 | #' 86 | #' This function behaves like \code{ggsave} but automatically embeds the fira 87 | #' font if the output format requires it. Install 64-bit GhostScript for this 88 | #' functionality. Currently only works automatically on Windows. For other 89 | #' platforms, run the following with the _correct_ location to the installed 90 | #' GhostScript Binary: Sys.setenv(R_GSCMD = "bin/gs/gs9.23/binaryname") 91 | #' 92 | #' @param filename path to a file 93 | #' @param device which type of output device to use 94 | #' @param ... other arguments passed to ggsave 95 | #' 96 | #' @seealso \code{\link[ggplot2]{ggsave}} 97 | #' 98 | #' @export 99 | firaSave <- function(filename = "plot.pdf", device = "pdf", ...) { 100 | needsFont <- device == "pdf" || device == "eps" || device == "ps" 101 | 102 | # set up ghostscript if needed 103 | if (Sys.getenv("R_GSCMD") == "" && needsFont) setupGhostScript() 104 | 105 | # save the image 106 | ggplot2::ggsave(filename = filename, device = device, ...) 107 | 108 | if (needsFont) extrafont::embed_fonts(filename) 109 | } 110 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 |
Ready-to-use ggplot2 theme
3 |

4 | DOI 5 | test 6 |

7 | 8 | 9 |
10 | 11 | This is a `ggplot2` theme I use for almost all my plots. You can use it and adapt it if you want. It's designed to be truly plug-and-play. See [below](#example-plots) for examples. 12 | 13 |

14 |
15 | 16 |
17 |

18 | 19 | 20 | As with any software project, this has a collection of dependencies it builds on: 21 | 22 | - The [trafford data lab theme](https://github.com/traffordDataLab/assets/blob/master/theme/ggplot2/theme_lab.R) was one of the main inspirations. 23 | - It uses Mozilla's [Fira Sans](https://mozilla.github.io/Fira/) font because it is beautiful. 24 | - Fonts in `R` graphics are notoriously difficult. The package [`extrafont`](https://github.com/wch/extrafont) solves this. 25 | - Of course, one of the main dependencies is [`ggplot2`](https://github.com/tidyverse/ggplot2). 26 | - I used [coolors](https://coolors.co/) to generate the colours. 27 | 28 | 29 | ## Installation 30 | On mac computers, first install the [`Fira Sans`](https://fonts.google.com/specimen/Fira+Sans) font to the font book. 31 | 32 | 33 | ```R 34 | remotes::install_github("vankesteren/firatheme") 35 | ``` 36 | 37 | The preferred way to save plots is via the `firaSave()` function. For png output, this works out of the box. 38 | 39 | ### PDF output 40 | For pdf output, `firaSave()` embeds the Fira Sans font by default using the `extrafont` package. The requirement for this is `ghostscript`: 41 | 42 | #### On windows 43 | 1. Install [ghostscript](https://www.ghostscript.com/download/gsdnld.html). 44 | 2. Restart your `R` or `RStudio` application 45 | 3. Now you can output! 46 | 47 | #### On mac 48 | 1. (install homebrew) 49 | 2. `brew install ghostscript` 50 | 3. Restart your `R` or `RStudio` application 51 | 4. Now you can output! 52 | 53 | #### On linux 54 | 1. Install ghostscript so that it is on the `PATH`. 55 | 2. Restart your `R` or `RStudio` application 56 | 3. Now you can output! 57 | 58 | ## Example plots 59 | Below you can find some example plots made using `theme_fira()` 60 | 61 | ### Dots and lines 62 | ```R 63 | library(ggplot2) 64 | library(firatheme) 65 | 66 | ggplot(mtcars, aes(x = mpg*0.43, y = wt*0.4535924, colour = factor(cyl))) + 67 | geom_point(size = 2) + geom_smooth(se = FALSE) + 68 | labs(title = "Car weight vs efficiency", 69 | x = "Efficiency (km/l)", 70 | y = "Weight (1000 kg)", 71 | colour = "Cylinders") + 72 | theme_fira() + 73 | scale_colour_fira() 74 | 75 | firaSave("plot.png", device = "png") 76 | ``` 77 | ![plt](./img/plot.png) 78 | 79 | ### Bar graph 80 | 81 | ```R 82 | library(ggplot2) 83 | library(firatheme) 84 | 85 | ggplot(chickwts, aes(x = feed, y = weight)) + 86 | geom_bar(stat = "identity", width=0.8, fill = firaCols[1]) + 87 | labs(title = "Chicken weights by feed type", 88 | y = "Weight (grams)", 89 | x = "") + 90 | theme_fira() 91 | ``` 92 | 93 | ![chk](./img/chick.png) 94 | 95 | 96 | ### Boxplot 97 | 98 | ```R 99 | library(ggplot2) 100 | library(firatheme) 101 | 102 | ggplot(iris, aes(y = Sepal.Length, x = Species, fill = Species)) + 103 | geom_boxplot(col = firaCols[4], width = 0.5, size = 1) + 104 | labs(y = "Sepal Length", title = "Iris data") + 105 | theme_fira() + 106 | scale_fill_fira() + 107 | theme(legend.position = "none") 108 | ``` 109 | 110 | ![iris](./img/iris.png) 111 | 112 | ### More lines 113 | ```R 114 | library(ggplot2) 115 | library(firatheme) 116 | 117 | ggplot(airquality, aes(y = Ozone, x = 1:nrow(airquality))) + 118 | geom_line(colour = firaCols[2], size = 0.7) + 119 | geom_point(colour = firaCols[2], size = 1.7) + 120 | geom_smooth(colour = firaCols[1], size = 0.7, se = FALSE) + 121 | labs(title = "Ozone in New York", x = "Days") + 122 | theme_fira() 123 | ``` 124 | 125 | ![oz](./img/ozone.png) 126 | 127 | 128 | ## Colours 129 | The colour palette of `firatheme` is available through `firaCols` and `firaPalette()`. In `ggplot` objects, you should use `scale_fill_fira()` and `scale_colour_fira()` for mapped variables. Optionally, the argument `continuous = TRUE` can be passed. 130 | ![col](./img/firacols.png) 131 | 132 | Using the palette functions, you can get any number of colours from the palette, for example `firaPalette(n = 25)` --- the last image in the figure below: 133 | ![cols](./img/firapalette.png) 134 | 135 | ## Citation 136 | If you want to cite `firatheme`, you can use the following `bibtex`: 137 | 138 | ```bibtex 139 | @article{vankesteren2021firatheme, 140 | title = {vankesteren/firatheme: firatheme version 0.2.4}, 141 | DOI = {10.5281/zenodo.4679413}, 142 | publisher = {Zenodo}, 143 | author = {Erik-Jan van Kesteren}, 144 | year = {2021}, 145 | month = {apr} 146 | } 147 | ``` 148 | -------------------------------------------------------------------------------- /firatheme.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | 15 | AutoAppendNewline: Yes 16 | StripTrailingWhitespace: Yes 17 | 18 | BuildType: Package 19 | PackageUseDevtools: Yes 20 | PackageInstallArgs: --no-multiarch --with-keep.source 21 | -------------------------------------------------------------------------------- /img/chick.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vankesteren/firatheme/006d4d04db054e8678278124829e4c3adb386214/img/chick.png -------------------------------------------------------------------------------- /img/firacols.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vankesteren/firatheme/006d4d04db054e8678278124829e4c3adb386214/img/firacols.png -------------------------------------------------------------------------------- /img/firapalette.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vankesteren/firatheme/006d4d04db054e8678278124829e4c3adb386214/img/firapalette.png -------------------------------------------------------------------------------- /img/iris.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vankesteren/firatheme/006d4d04db054e8678278124829e4c3adb386214/img/iris.png -------------------------------------------------------------------------------- /img/ozone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vankesteren/firatheme/006d4d04db054e8678278124829e4c3adb386214/img/ozone.png -------------------------------------------------------------------------------- /img/plot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vankesteren/firatheme/006d4d04db054e8678278124829e4c3adb386214/img/plot.png -------------------------------------------------------------------------------- /img/title.svg: -------------------------------------------------------------------------------- 1 | firatheme -------------------------------------------------------------------------------- /inst/font/FiraSans-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vankesteren/firatheme/006d4d04db054e8678278124829e4c3adb386214/inst/font/FiraSans-Bold.ttf -------------------------------------------------------------------------------- /inst/font/FiraSans-BoldItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vankesteren/firatheme/006d4d04db054e8678278124829e4c3adb386214/inst/font/FiraSans-BoldItalic.ttf -------------------------------------------------------------------------------- /inst/font/FiraSans-Italic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vankesteren/firatheme/006d4d04db054e8678278124829e4c3adb386214/inst/font/FiraSans-Italic.ttf -------------------------------------------------------------------------------- /inst/font/FiraSans-Medium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vankesteren/firatheme/006d4d04db054e8678278124829e4c3adb386214/inst/font/FiraSans-Medium.ttf -------------------------------------------------------------------------------- /inst/font/FiraSans-MediumItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vankesteren/firatheme/006d4d04db054e8678278124829e4c3adb386214/inst/font/FiraSans-MediumItalic.ttf -------------------------------------------------------------------------------- /inst/font/FiraSans-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vankesteren/firatheme/006d4d04db054e8678278124829e4c3adb386214/inst/font/FiraSans-Regular.ttf -------------------------------------------------------------------------------- /inst/font/OFL.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012-2015, The Mozilla Foundation and Telefonica S.A. 2 | 3 | This Font Software is licensed under the SIL Open Font License, Version 1.1. 4 | This license is copied below, and is also available with a FAQ at: 5 | http://scripts.sil.org/OFL 6 | 7 | 8 | ----------------------------------------------------------- 9 | SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 10 | ----------------------------------------------------------- 11 | 12 | PREAMBLE 13 | The goals of the Open Font License (OFL) are to stimulate worldwide 14 | development of collaborative font projects, to support the font creation 15 | efforts of academic and linguistic communities, and to provide a free and 16 | open framework in which fonts may be shared and improved in partnership 17 | with others. 18 | 19 | The OFL allows the licensed fonts to be used, studied, modified and 20 | redistributed freely as long as they are not sold by themselves. The 21 | fonts, including any derivative works, can be bundled, embedded, 22 | redistributed and/or sold with any software provided that any reserved 23 | names are not used by derivative works. The fonts and derivatives, 24 | however, cannot be released under any other type of license. The 25 | requirement for fonts to remain under this license does not apply 26 | to any document created using the fonts or their derivatives. 27 | 28 | DEFINITIONS 29 | "Font Software" refers to the set of files released by the Copyright 30 | Holder(s) under this license and clearly marked as such. This may 31 | include source files, build scripts and documentation. 32 | 33 | "Reserved Font Name" refers to any names specified as such after the 34 | copyright statement(s). 35 | 36 | "Original Version" refers to the collection of Font Software components as 37 | distributed by the Copyright Holder(s). 38 | 39 | "Modified Version" refers to any derivative made by adding to, deleting, 40 | or substituting -- in part or in whole -- any of the components of the 41 | Original Version, by changing formats or by porting the Font Software to a 42 | new environment. 43 | 44 | "Author" refers to any designer, engineer, programmer, technical 45 | writer or other person who contributed to the Font Software. 46 | 47 | PERMISSION & CONDITIONS 48 | Permission is hereby granted, free of charge, to any person obtaining 49 | a copy of the Font Software, to use, study, copy, merge, embed, modify, 50 | redistribute, and sell modified and unmodified copies of the Font 51 | Software, subject to the following conditions: 52 | 53 | 1) Neither the Font Software nor any of its individual components, 54 | in Original or Modified Versions, may be sold by itself. 55 | 56 | 2) Original or Modified Versions of the Font Software may be bundled, 57 | redistributed and/or sold with any software, provided that each copy 58 | contains the above copyright notice and this license. These can be 59 | included either as stand-alone text files, human-readable headers or 60 | in the appropriate machine-readable metadata fields within text or 61 | binary files as long as those fields can be easily viewed by the user. 62 | 63 | 3) No Modified Version of the Font Software may use the Reserved Font 64 | Name(s) unless explicit written permission is granted by the corresponding 65 | Copyright Holder. This restriction only applies to the primary font name as 66 | presented to the users. 67 | 68 | 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font 69 | Software shall not be used to promote, endorse or advertise any 70 | Modified Version, except to acknowledge the contribution(s) of the 71 | Copyright Holder(s) and the Author(s) or with their explicit written 72 | permission. 73 | 74 | 5) The Font Software, modified or unmodified, in part or in whole, 75 | must be distributed entirely under this license, and must not be 76 | distributed under any other license. The requirement for fonts to 77 | remain under this license does not apply to any document created 78 | using the Font Software. 79 | 80 | TERMINATION 81 | This license becomes null and void if any of the above conditions are 82 | not met. 83 | 84 | DISCLAIMER 85 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 86 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF 87 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 88 | OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE 89 | COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 90 | INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL 91 | DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 92 | FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM 93 | OTHER DEALINGS IN THE FONT SOFTWARE. 94 | -------------------------------------------------------------------------------- /man/firaCols.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/colours.R 3 | \docType{data} 4 | \name{firaCols} 5 | \alias{firaCols} 6 | \title{Fira theme colours} 7 | \format{ 8 | An object of class \code{character} of length 5. 9 | } 10 | \usage{ 11 | firaCols 12 | } 13 | \description{ 14 | This is a vector with 5 colours to be used in palettes and other visual 15 | elements. 16 | } 17 | \seealso{ 18 | \code{\link{firaPalette}} 19 | } 20 | \keyword{datasets} 21 | -------------------------------------------------------------------------------- /man/firaPalette.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/colours.R 3 | \name{firaPalette} 4 | \alias{firaPalette} 5 | \title{Fira theme palette} 6 | \usage{ 7 | firaPalette(n = 5) 8 | } 9 | \arguments{ 10 | \item{n}{the number of colours to output} 11 | } 12 | \description{ 13 | This function outputs n colours from the fira ggplot2 theme palette 14 | } 15 | \seealso{ 16 | \code{\link{firaCols}} 17 | } 18 | -------------------------------------------------------------------------------- /man/firaSave.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/theme_fira.R 3 | \name{firaSave} 4 | \alias{firaSave} 5 | \title{Save plots that use the fira theme} 6 | \usage{ 7 | firaSave(filename = "plot.pdf", device = "pdf", ...) 8 | } 9 | \arguments{ 10 | \item{filename}{path to a file} 11 | 12 | \item{device}{which type of output device to use} 13 | 14 | \item{...}{other arguments passed to ggsave} 15 | } 16 | \description{ 17 | This function behaves like \code{ggsave} but automatically embeds the fira 18 | font if the output format requires it. Install 64-bit GhostScript for this 19 | functionality. Currently only works automatically on Windows. For other 20 | platforms, run the following with the _correct_ location to the installed 21 | GhostScript Binary: Sys.setenv(R_GSCMD = "bin/gs/gs9.23/binaryname") 22 | } 23 | \seealso{ 24 | \code{\link[ggplot2]{ggsave}} 25 | } 26 | -------------------------------------------------------------------------------- /man/scale_fira.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/colours.R 3 | \name{scale_fill_fira} 4 | \alias{scale_fill_fira} 5 | \alias{scale_colour_fira} 6 | \alias{scale_color_fira} 7 | \title{Fira discrete colour scales} 8 | \usage{ 9 | scale_fill_fira(..., continuous = FALSE) 10 | 11 | scale_colour_fira(..., continuous = FALSE) 12 | 13 | scale_color_fira(..., continuous = FALSE) 14 | } 15 | \arguments{ 16 | \item{...}{ 17 | Arguments passed on to \code{\link[ggplot2:discrete_scale]{discrete_scale}} 18 | \describe{ 19 | \item{\code{palette}}{A palette function that when called with a single integer 20 | argument (the number of levels in the scale) returns the values that 21 | they should take (e.g., \code{\link[scales:hue_pal]{scales::hue_pal()}}).} 22 | \item{\code{breaks}}{One of: 23 | \itemize{ 24 | \item \code{NULL} for no breaks 25 | \item \code{waiver()} for the default breaks (the scale limits) 26 | \item A character vector of breaks 27 | \item A function that takes the limits as input and returns breaks 28 | as output 29 | }} 30 | \item{\code{limits}}{One of: 31 | \itemize{ 32 | \item \code{NULL} to use the default scale values 33 | \item A character vector that defines possible values of the scale and their 34 | order 35 | \item A function that accepts the existing (automatic) values and returns 36 | new ones 37 | }} 38 | \item{\code{drop}}{Should unused factor levels be omitted from the scale? 39 | The default, \code{TRUE}, uses the levels that appear in the data; 40 | \code{FALSE} uses all the levels in the factor.} 41 | \item{\code{na.translate}}{Unlike continuous scales, discrete scales can easily show 42 | missing values, and do so by default. If you want to remove missing values 43 | from a discrete scale, specify \code{na.translate = FALSE}.} 44 | \item{\code{scale_name}}{The name of the scale that should be used for error messages 45 | associated with this scale.} 46 | \item{\code{name}}{The name of the scale. Used as the axis or legend title. If 47 | \code{waiver()}, the default, the name of the scale is taken from the first 48 | mapping used for that aesthetic. If \code{NULL}, the legend title will be 49 | omitted.} 50 | \item{\code{labels}}{One of: 51 | \itemize{ 52 | \item \code{NULL} for no labels 53 | \item \code{waiver()} for the default labels computed by the 54 | transformation object 55 | \item A character vector giving labels (must be same length as \code{breaks}) 56 | \item A function that takes the breaks as input and returns labels 57 | as output 58 | }} 59 | \item{\code{expand}}{For position scales, a vector of range expansion constants used to add some 60 | padding around the data to ensure that they are placed some distance 61 | away from the axes. Use the convenience function \code{\link[ggplot2:expansion]{expansion()}} 62 | to generate the values for the \code{expand} argument. The defaults are to 63 | expand the scale by 5\% on each side for continuous variables, and by 64 | 0.6 units on each side for discrete variables.} 65 | \item{\code{guide}}{A function used to create a guide or its name. See 66 | \code{\link[ggplot2:guides]{guides()}} for more information.} 67 | \item{\code{position}}{For position scales, The position of the axis. 68 | \code{left} or \code{right} for y axes, \code{top} or \code{bottom} for x axes.} 69 | \item{\code{super}}{The super class to use for the constructed scale} 70 | }} 71 | 72 | \item{continuous}{whether the associated variable should be considered 73 | continuous. Typically used after "Error: Continuous value supplied to 74 | discrete scale"} 75 | } 76 | \description{ 77 | Colour scales belonging to the fira theme 78 | } 79 | \seealso{ 80 | \code{\link{firaPalette}} 81 | } 82 | -------------------------------------------------------------------------------- /man/theme_fira.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/theme_fira.R 3 | \name{theme_fira} 4 | \alias{theme_fira} 5 | \title{Fira theme} 6 | \usage{ 7 | theme_fira(family = "Fira Sans") 8 | } 9 | \arguments{ 10 | \item{family}{Change the font family. Defaults to Fira Sans} 11 | } 12 | \value{ 13 | ggplot theme 14 | } 15 | \description{ 16 | This theme uses Mozilla's Fira Sans as its font. 17 | Save to pdf using \code{firaSave()}. 18 | } 19 | \examples{ 20 | library(ggplot2) 21 | 22 | ggplot(mtcars, aes(x = mpg*0.43, y = wt*0.4535924, colour = factor(cyl))) + 23 | geom_point(size = 2) + 24 | labs(title = "Car weight vs efficiency", 25 | subtitle = "Using sensible metrics", 26 | x = "Efficiency (km/l)", 27 | y = "Weight (1000 kg)", 28 | colour = "Cylinders") + 29 | theme_fira() + 30 | scale_colour_fira() 31 | 32 | } 33 | \seealso{ 34 | \code{\link{firaSave}} 35 | } 36 | --------------------------------------------------------------------------------