diff --git a/.gitignore b/.gitignore index e6950d7..21165a9 100644 --- a/.gitignore +++ b/.gitignore @@ -10,7 +10,8 @@ # produced vignettes vignettes/*.html vignettes/*.pdf -# misc +misc/builds +misc/pre-build .Rdata core inst/doc diff --git a/.travis.yml b/.travis.yml index c51dcfd..0f50a76 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ warnings_are_errors: true r_packages: - rmarkdown - ggplot2 + - testthat r_github_packages: - jimhester/covr diff --git a/DESCRIPTION b/DESCRIPTION index 74c9c02..688fe6f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,12 +1,14 @@ Package: ggthemr Title: Themes for ggplot2 Description: Colour schemes and layouts for ggplot2. -Version: 1.0.1 +Version: 1.0.2 Author: Ciaran Tobin -Imports: scales +Imports: + scales Depends: R (>= 3.0.0), ggplot2 License: GPL-3 LazyData: true Maintainer: 'Ciaran Tobin' +RoxygenNote: 5.0.1 diff --git a/NAMESPACE b/NAMESPACE index 1abca27..f23aae9 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,4 +1,4 @@ -# Generated by roxygen2 (4.1.1): do not edit by hand +# Generated by roxygen2: do not edit by hand S3method(colour_plot,character) S3method(colour_plot,ggthemr) diff --git a/R/ggthemr.R b/R/ggthemr.R index 1c44535..9073eff 100644 --- a/R/ggthemr.R +++ b/R/ggthemr.R @@ -1,20 +1,17 @@ -#' Set theme for ggplot2 -#' -#' Set theme to be applied to all subsequent ggplots. -#' -#' @param palette Colour scheme by name or ggtheme object. -#' @param layout The layout of gridlines, axes etc. -#' @param spacing A numeric value of how much space should exist on any given plot. Low values will result in more cramped plots, higher values will have more whitespace. -#' @param text_size base text size. -#' @param type Set to 'inner' where the background colour should not extend past strictly the plot area (or "panel" in ggplot2 terminology). 'outer' will apply the background colour to the entire plot. -#' @param line_weight The thickness of axes lines and gridlines. Useful for saving plots at different resolutions. -#' @param pos Where the new scales are stored. -#' @param envir The environment where the new scales are stored. -#' @export -#' @author Ciaran Tobin -#' @examples +#' @title Set theme for ggplot2 +#' @description Set theme to be applied to all subsequent ggplots. +#' @param palette Colour scheme by name or ggtheme object. +#' @param layout The layout of gridlines, axes etc. +#' @param spacing A numeric value of how much space should exist on any given plot. Low values will result in more cramped plots, higher values will have more whitespace. +#' @param text_size base text size. +#' @param type Set to 'inner' where the background colour should not extend past strictly the plot area (or "panel" in ggplot2 terminology). 'outer' will apply the background colour to the entire plot. +#' @param line_weight The thickness of axes lines and gridlines. Useful for saving plots at different resolutions. +#' @param pos Where the new scales are stored. +#' @param envir The environment where the new scales are stored. +#' @export +#' @author Ciaran Tobin +#' @examples #' ggthemr('pale', layout = 'scientific', spacing = 2, type = 'inner') - ggthemr <- function(palette = 'dust', layout = 'clear', spacing = 1.6, text_size = 12, type = 'inner', line_weight = 0.5, pos = 1, envir = as.environment(pos)) { diff --git a/R/ggthemr_current.R b/R/ggthemr_current.R index 3e5c4d5..28ca1ea 100644 --- a/R/ggthemr_current.R +++ b/R/ggthemr_current.R @@ -1,6 +1,6 @@ #' @title Store Theme #' @description Store ggthemr theme. -ggthemr_current <- (function () { +ggthemr_current <- local({ themr <- NULL list( get = function () { @@ -21,7 +21,7 @@ ggthemr_current <- (function () { themr <<- NULL } ) -})() +}) #' @title Get Current Theme @@ -39,4 +39,4 @@ is_ggthemr_active <- function () ggthemr_current$is_set() clear_themr <- function () - ggthemr_current$clear() \ No newline at end of file + ggthemr_current$clear() diff --git a/R/no_axes.R b/R/no_axes.R index 711e291..1c904ce 100644 --- a/R/no_axes.R +++ b/R/no_axes.R @@ -32,6 +32,7 @@ no_y_axis <- function () #' @title Remove ggplot2 x-axis line +#' @description Do not show x-axis line #' @author Ciaran Tobin #' @seealso \code{\link{no_y_line}} #' @export @@ -40,6 +41,7 @@ no_x_line <- function () #' @title Remove ggplot2 y-axis line +#' @description Do not show y-axis line #' @author Ciaran Tobin #' @seealso \code{\link{no_x_line}} #' @export @@ -48,6 +50,7 @@ no_y_line <- function () #' @title Remove ggplot2 x-axis text/labels +#' @description Do not show x-axis text/labels #' @author Ciaran Tobin #' @seealso \code{\link{no_y_text}} #' @export @@ -56,6 +59,7 @@ no_x_text <- function () #' @title Remove ggplot2 y-axis text/labels +#' @description Do not show y-axis text/labels #' @author Ciaran Tobin #' @seealso \code{\link{no_x_text}} #' @export @@ -64,6 +68,7 @@ no_y_text <- function () #' @title Remove ggplot2 tick marks +#' @description Do not show tick marks for all axes #' @author Ciaran Tobin #' @seealso \code{\link{no_x_ticks}}, \code{\link{no_y_ticks}} #' @export @@ -72,6 +77,7 @@ no_ticks <- function () #' @title Remove ggplot2 x-axis tick marks +#' @description Do not show tick marks for x-axis #' @author Ciaran Tobin #' @seealso \code{\link{no_ticks}}, \code{\link{no_y_ticks}} #' @export @@ -80,6 +86,7 @@ no_x_ticks <- function () #' @title Remove ggplot2 y-axis tick marks +#' @description Do not show tick marks for y-axis #' @author Ciaran Tobin #' @seealso \code{\link{no_ticks}}, \code{\link{no_x_ticks}} #' @export @@ -88,6 +95,7 @@ no_y_ticks <- function () #' @title Remove ggplot2 axes titles +#' @description Do not show titles for all axes #' @author Ciaran Tobin #' @seealso \code{\link{no_x_title}}, \code{\link{no_y_title}} #' @export @@ -96,6 +104,7 @@ no_axes_titles <- function () #' @title Remove ggplot2 x-axis titles +#' @description Do not show x-axis title #' @author Ciaran Tobin #' @seealso \code{\link{no_axes_titles}}, \code{\link{no_y_title}} #' @export @@ -104,6 +113,7 @@ no_x_title <- function () #' @title Remove ggplot2 y-axis titles +#' @description Do not show y-axis title #' @author Ciaran Tobin #' @seealso \code{\link{no_axes_titles}}, \code{\link{no_x_title}} #' @export diff --git a/R/no_gridlines.R b/R/no_gridlines.R index 2329414..abe611b 100644 --- a/R/no_gridlines.R +++ b/R/no_gridlines.R @@ -17,7 +17,7 @@ no_x_gridlines <- function () #' @export -#' @describeIn no_x_gridlines +#' @rdname no_x_gridlines no_vertical_gridlines <- no_x_gridlines @@ -31,35 +31,41 @@ no_y_gridlines <- function () #' @export -#' @describeIn no_y_gridlines +#' @rdname no_y_gridlines no_horizontal_gridlines <- no_y_gridlines #' @title Remove major gridlines +#' @description Do not show major gridlines #' @export no_major_gridlines <- function () theme(panel.grid.major = element_blank()) #' @title Remove minor gridlines +#' @description Do not show minor gridlines #' @export no_minor_gridlines <- function () theme(panel.grid.minor = element_blank()) #' @title Remove major x gridlines +#' @description Do not show major gridlines for x-axis #' @export no_major_x_gridlines <- function () theme(panel.grid.major.x = element_blank()) #' @title Remove minor x gridlines +#' @description Do not show minor gridlines for x-axis #' @export no_minor_x_gridlines <- function () theme(panel.grid.minor.x = element_blank()) #' @title Remove major y gridlines +#' @description Do not show major gridlines for y-axis #' @export no_major_y_gridlines <- function () theme(panel.grid.major.y = element_blank()) #' @title Remove minor y gridlines +#' @description Do not show minor gridlines for y-axis #' @export no_minor_y_gridlines <- function () theme(panel.grid.minor.y = element_blank()) \ No newline at end of file diff --git a/R/no_title.R b/R/no_title.R index 82ca6af..2f20a0f 100644 --- a/R/no_title.R +++ b/R/no_title.R @@ -1,4 +1,5 @@ #' @title Remove ggplot2 title +#' @description Remove the plot title #' @export #' @author Ciaran Tobin no_title <- function () diff --git a/R/set_theme.R b/R/set_theme.R index bc5e613..c28cdfe 100644 --- a/R/set_theme.R +++ b/R/set_theme.R @@ -38,10 +38,8 @@ set_theme <- function (palette, layout, spacing, text_size, type, line_weight) { margin=margin(), size = rel(0.8), colour = text_colour), - strip.text = element_text( - debug=FALSE, - margin=margin(), - size = rel(0.8)), + axis.text.x.top = NULL, + axis.text.y.right = NULL, axis.line = element_line( colour = line_colour), axis.line.x = layout$axis.line.x(colour = line_colour), @@ -63,20 +61,25 @@ set_theme <- function (palette, layout, spacing, text_size, type, line_weight) { axis.title.x = element_text( debug=FALSE, margin=margin(), - vjust=x_title_spacing(spacing)), + vjust=x_title_spacing(spacing)), + axis.title.x.top = NULL, axis.title.y = element_text( debug=FALSE, margin=margin(), angle = 90, vjust=y_title_spacing(spacing)), + axis.title.y.right = NULL, axis.ticks.length = grid::unit(0.15, "cm"), legend.background = element_rect( colour = ifelse(inner, 'white', palette$background), fill = ifelse(inner, 'white', palette$background)), - legend.margin = grid::unit(0.2 * spacing, "cm"), + legend.margin = NULL, + legend.spacing = grid::unit(0.2 * spacing, "cm"), legend.key = element_rect( colour = ifelse(inner, 'white', palette$background), fill = palette$background), + legend.spacing.x = NULL, + legend.spacing.y = NULL, legend.key.size = grid::unit( 1.2, "lines"), legend.key.height = NULL, @@ -97,15 +100,18 @@ set_theme <- function (palette, layout, spacing, text_size, type, line_weight) { legend.direction = NULL, legend.justification = "center", legend.box = NULL, + legend.box.margin = NULL, + legend.box.background = NULL, + legend.box.spacing = NULL, panel.background = element_rect( fill = palette$background, colour = NA), panel.border = element_blank(), panel.grid.major = layout$panel.grid.major(colour = palette$gridline), panel.grid.minor = layout$panel.grid.minor(colour = palette$gridline), - panel.margin = grid::unit(0.5 * spacing, 'cm'), - panel.margin.x = NULL, - panel.margin.y = NULL, + panel.spacing = grid::unit(0.5 * spacing, 'cm'), + panel.spacing.x = NULL, + panel.spacing.y = NULL, panel.ontop = FALSE, strip.background = element_rect( fill = ifelse(inner, 'white', palette$background), @@ -124,15 +130,18 @@ set_theme <- function (palette, layout, spacing, text_size, type, line_weight) { size = rel(1.1)), strip.switch.pad.grid = grid::unit(0, 'cm'), strip.switch.pad.wrap = grid::unit(0, 'cm'), + strip.placement = NULL, plot.background = element_rect( colour = ifelse(inner, 'white', palette$background), fill = ifelse(inner, 'white', palette$background)), plot.title = element_text( debug=FALSE, - margin=margin(), - size = rel(1.2), - vjust = spacing + 0.2, + margin=margin(0, 0, 6.6, 0), + size = rel(1.2), + vjust = spacing, face='bold'), + plot.subtitle = NULL, + plot.caption = NULL, plot.margin = grid::unit(c(0.625, 0.625, 0.625, 0.625) * spacing, 'cm'), complete = TRUE )) diff --git a/README.Rmd b/README.Rmd index 32004be..b6a58de 100644 --- a/README.Rmd +++ b/README.Rmd @@ -1,8 +1,19 @@ +--- +output: + md_document: + variant: markdown_github + toc: true +--- + + + ```{r echo=FALSE} suppressPackageStartupMessages(library(ggplot2)) suppressPackageStartupMessages(library(gridExtra)) library(ggthemr) example_plot <- ggplot(diamonds, aes(price, fill = factor(cut))) + geom_histogram(binwidth = 850) + xlab('Price (USD)') + ylab('Count') + scale_x_continuous(label = function(x) paste0(x / 1000, 'k')) + list(theme(legend.position = 'none'), scale_y_continuous(label = function(x) format(x, big.mark = ",", scientific = FALSE))) +source('scripts/preview_theme.R') +source('scripts/preview_layout.R') ``` ggthemr @@ -24,7 +35,7 @@ Installation This package is still under development and isn't too stable yet, but can be installed using [devtools](http://cran.r-project.org/web/packages/devtools/index.html). ```{r eval=FALSE} -devtools::install_github('ggthemr', 'cttobin') +devtools::install_github('cttobin/ggthemr') ``` Usage @@ -47,9 +58,10 @@ Further Development ------------------------- Features on the way: + * More palettes and layouts. * Options to control fonts. -* Ability to reset themes back to default. +* Ability to reset themes back to default. * Theme modifiers (so you can do things like `plot + no_legend()`, `plot + no_axes()` etc.). @@ -64,132 +76,133 @@ There are a wide variety of themes in this package (and more on the way). Some o [Base 16](https://github.com/chriskempson/base16) - ```{r fig.width=10, fig.height=6, echo=FALSE} - ggthemr('flat', spacing = 0.5, type = 'inner') - ggthemr:::preview_theme() - ``` +```{r fig.width=10, fig.height=6, echo=FALSE} +ggthemr('flat', spacing = 0.5, type = 'inner') +preview_theme() +``` ### flat dark [Base 16](https://github.com/chriskempson/base16) - - ```{r fig.width=10, fig.height=6, echo=FALSE} - ggthemr('flat dark', spacing = 0.5, type = 'inner') - ggthemr:::preview_theme() - ``` + +```{r fig.width=10, fig.height=6, echo=FALSE} +ggthemr('flat dark', spacing = 0.5, type = 'inner') +preview_theme() +``` ### camoflauge - - ```{r fig.width=10, fig.height=6, echo=FALSE} - ggthemr('camoflauge', spacing = 0.5, type = 'inner') - ggthemr:::preview_theme() - ``` - + +```{r fig.width=10, fig.height=6, echo=FALSE} +ggthemr('camoflauge', spacing = 0.5, type = 'inner') +preview_theme() +``` + ### chalk - - ```{r fig.width=10, fig.height=6, echo=FALSE} - ggthemr('chalk', spacing = 0.5, type = 'inner') - ggthemr:::preview_theme() - ``` - + +```{r fig.width=10, fig.height=6, echo=FALSE} +ggthemr('chalk', spacing = 0.5, type = 'inner') +preview_theme() +``` + ### copper - - ```{r fig.width=10, fig.height=6, echo=FALSE} - ggthemr('copper', spacing = 0.5, type = 'inner') - ggthemr:::preview_theme() - ``` - + +```{r fig.width=10, fig.height=6, echo=FALSE} +ggthemr('copper', spacing = 0.5, type = 'inner') +preview_theme() +``` + ### dust - - ```{r fig.width=10, fig.height=6, echo=FALSE} - ggthemr('dust', spacing = 0.5, type = 'inner') - ggthemr:::preview_theme() - ``` - + +```{r fig.width=10, fig.height=6, echo=FALSE} +ggthemr('dust', spacing = 0.5, type = 'inner') +preview_theme() +``` + ### earth - - ```{r fig.width=10, fig.height=6, echo=FALSE} - ggthemr('earth', spacing = 0.5, type = 'inner') - ggthemr:::preview_theme() - ``` - + +```{r fig.width=10, fig.height=6, echo=FALSE} +ggthemr('earth', spacing = 0.5, type = 'inner') +preview_theme() +``` + ### fresh - - ```{r fig.width=10, fig.height=6, echo=FALSE} - ggthemr('fresh', spacing = 0.5, type = 'inner') - ggthemr:::preview_theme() - ``` - + +```{r fig.width=10, fig.height=6, echo=FALSE} +ggthemr('fresh', spacing = 0.5, type = 'inner') +preview_theme() +``` + ### grape - - ```{r fig.width=10, fig.height=6, echo=FALSE} - ggthemr('grape', spacing = 0.5, type = 'inner') - ggthemr:::preview_theme() - ``` - + +```{r fig.width=10, fig.height=6, echo=FALSE} +ggthemr('grape', spacing = 0.5, type = 'inner') +preview_theme() +``` + ### grass - - ```{r fig.width=10, fig.height=6, echo=FALSE} - ggthemr('grass', spacing = 0.5, type = 'inner') - ggthemr:::preview_theme() - ``` - + +```{r fig.width=10, fig.height=6, echo=FALSE} +ggthemr('grass', spacing = 0.5, type = 'inner') +preview_theme() +``` + ### greyscale - - ```{r fig.width=10, fig.height=6, echo=FALSE} - ggthemr('greyscale', spacing = 0.5, type = 'inner') - ggthemr:::preview_theme() - ``` - + +```{r fig.width=10, fig.height=6, echo=FALSE} +ggthemr('greyscale', spacing = 0.5, type = 'inner') +preview_theme() +``` + ### light - - ```{r fig.width=10, fig.height=6, echo=FALSE} - ggthemr('light', spacing = 0.5, type = 'inner') - ggthemr:::preview_theme() - ``` - + +```{r fig.width=10, fig.height=6, echo=FALSE} +ggthemr('light', spacing = 0.5, type = 'inner') +preview_theme() +``` + ### lilac - - ```{r fig.width=10, fig.height=6, echo=FALSE} - ggthemr('lilac', spacing = 0.5, type = 'inner') - ggthemr:::preview_theme() - ``` - + +```{r fig.width=10, fig.height=6, echo=FALSE} +ggthemr('lilac', spacing = 0.5, type = 'inner') +preview_theme() +``` + ### pale - - ```{r fig.width=10, fig.height=6, echo=FALSE} - ggthemr('pale', spacing = 0.5, type = 'inner') - ggthemr:::preview_theme() - ``` - + +```{r fig.width=10, fig.height=6, echo=FALSE} +ggthemr('pale', spacing = 0.5, type = 'inner') +preview_theme() +``` + ### sea - - ```{r fig.width=10, fig.height=6, echo=FALSE} - ggthemr('sea', spacing = 0.5, type = 'inner') - ggthemr:::preview_theme() - ``` - + +```{r fig.width=10, fig.height=6, echo=FALSE} +ggthemr('sea', spacing = 0.5, type = 'inner') +preview_theme() +``` + ### sky - - ```{r fig.width=10, fig.height=6, echo=FALSE} - ggthemr('sky', spacing = 0.5, type = 'inner') - ggthemr:::preview_theme() - ``` - + +```{r fig.width=10, fig.height=6, echo=FALSE} +ggthemr('sky', spacing = 0.5, type = 'inner') +preview_theme() +``` + ### solarized - - ```{r fig.width=10, fig.height=6, echo=FALSE} - ggthemr('solarized', spacing = 0.5, type = 'inner') - ggthemr:::preview_theme() - ``` - + +```{r fig.width=10, fig.height=6, echo=FALSE} +ggthemr('solarized', spacing = 0.5, type = 'inner') +preview_theme() +``` + Custom Palettes ------------------------- - + `define_palette()` lets you make your own themes that can be passed to `ggthemr()` just like any of the palettes above. Here's an example of a (probably ugly) palette using random colours: ``` {r fig.width=5.5, fig.height=4.5} # Random colours that aren't white. +set.seed(12345) random_colours <- sample(colors()[-c(1, 253, 361)], 10L) ugly <- define_palette( @@ -212,39 +225,39 @@ Layouts The layout of a theme controls the appearance and position of the axes, gridlines and text. Some folk prefer both major and minor gridlines, others prefer none or something in between. ### Clean - - ```{r fig.width=5.5, fig.height=3.5, echo=FALSE} - ggthemr('grape', layout = 'clean', spacing = 0.5) - ggthemr:::preview_layout() - ``` - + +```{r fig.width=5.5, fig.height=3.5, echo=FALSE} +ggthemr('grape', layout = 'clean', spacing = 0.5) +preview_layout() +``` + ### Clear (default) - - ```{r fig.width=5.5, fig.height=3.5, echo=FALSE} - ggthemr('grape', layout = 'clear', spacing = 0.5) - ggthemr:::preview_layout() - ``` - + +```{r fig.width=5.5, fig.height=3.5, echo=FALSE} +ggthemr('grape', layout = 'clear', spacing = 0.5) +preview_layout() +``` + ### Minimal - - ```{r fig.width=5.5, fig.height=3.5, echo=FALSE} - ggthemr('grape', layout = 'minimal', spacing = 0.5) - ggthemr:::preview_layout() - ``` + +```{r fig.width=5.5, fig.height=3.5, echo=FALSE} +ggthemr('grape', layout = 'minimal', spacing = 0.5) +preview_layout() +``` ### Plain - - ```{r fig.width=5.5, fig.height=3.5, echo=FALSE} - ggthemr('grape', layout = 'plain', spacing = 0.5) - ggthemr:::preview_layout() - ``` - + +```{r fig.width=5.5, fig.height=3.5, echo=FALSE} +ggthemr('grape', layout = 'plain', spacing = 0.5) +preview_layout() +``` + ### Scientific - - ```{r fig.width=5.5, fig.height=3.5, echo=FALSE} - ggthemr('grape', layout = 'scientific', spacing = 0.5) - ggthemr:::preview_layout() - ``` + +```{r fig.width=5.5, fig.height=3.5, echo=FALSE} +ggthemr('grape', layout = 'scientific', spacing = 0.5) +preview_layout() +``` Spacing ------------------------- @@ -253,17 +266,17 @@ Plot margins and space between axes titles and lines etc. is controlled with the ```{r fig.width=5.5, fig.height=3.5, echo=FALSE} ggthemr('earth', spacing = 0, type = 'outer') -ggthemr:::preview_layout() +preview_layout() ``` ```{r fig.width=5.5, fig.height=3.5, echo=FALSE} ggthemr('earth', spacing = 1, type = 'outer') -ggthemr:::preview_layout() +preview_layout() ``` ```{r fig.width=5.5, fig.height=3.5, echo=FALSE} ggthemr('earth', spacing = 2, type = 'outer') -ggthemr:::preview_layout() +preview_layout() ``` Type diff --git a/README.html b/README.html deleted file mode 100644 index 6dd46c2..0000000 --- a/README.html +++ /dev/null @@ -1,278 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - -
-

ggthemr

-

Themes for ggplot2. The idea of this package is that you can just set the theme and then forget about it. You shouldn’t have to change any of your existing code. There are several parts to a theme:

-
    -
  • Colour palette for the background, axes, gridlines, text etc.
  • -
  • Layout of axes lines and gridlines.
  • -
  • Spacing around plot and between elements (i.e. axes titles to axes lines etc). You can set the spacing to determine how compact or spread out a plot is.
  • -
  • Text size.
  • -
-

There are a number of preset palettes and layouts, and methods to create your own colour schemes.

-
-

Installation

-

This package is still under development and isn’t too stable yet, but can be installed using devtools.

-
devtools::install_github('ggthemr', 'cttobin')
-
-
-

Usage

-

To just set the colour scheme:

-
ggthemr('dust')
-

That’s it. Any ggplot you create from then on will have the theme applied. You can clear the theme and return to ggplot2’s default using:

-
ggthemr_reset()
-
-
-

Further Development

-

Features on the way: * More palettes and layouts. * Options to control fonts. * Ability to reset themes back to default. * Theme modifiers (so you can do things like plot + no_legend(), plot + no_axes() etc.).

-
-
-

Palettes

-

The palette determines the colours of everything in a plot including the background, layers, gridlines, title text, axes lines, axes text and axes titles. The swatch is the the name given to the set of colours strictly used in styling the geoms/layer elements (e.g. the points in geom_point(), bars in geom_bar() etc.). At least six colours have been supplied in each palette’s swatch.

-

There are a wide variety of themes in this package (and more on the way). Some of them serious business… others are delibrately stylish and might not be that good for use in proper publications.

-
-

flat

-

Base 16

-

-
-
-

flat dark

-

Base 16

-

-
-
-

camoflauge

-

-
-
-

chalk

-

-
-
-

copper

-

-
-
-

dust

-

-
-
-

earth

-

-
-
-

fresh

-

-
-
-

grape

-

-
-
-

grass

-

-
-
-

greyscale

-

-
-
-

light

-

-
-
-

lilac

-

-
-
-

pale

-

-
-
-

sea

-

-
-
-

sky

-

-
-
-

solarized

-

-
-
-
-

Custom Palettes

-

define_palette() lets you make your own themes that can be passed to ggthemr() just like any of the palettes above. Here’s an example of a (probably ugly) palette using random colours:

-
# Random colours that aren't white.
-random_colours <- sample(colors()[-c(1, 253, 361)], 10L)
-
-ugly <- define_palette(
-  swatch = random_colours,
-  gradient = c(lower = random_colours[1L], upper = random_colours[2L])
-)
-
-ggthemr(ugly)
-
-example_plot + ggtitle(':(')
-

-

You can define all elements of a palette using define_palette() including colours for the background, text, axes lines, swatch and gradients.

-
-
-

Layouts

-

The layout of a theme controls the appearance and position of the axes, gridlines and text. Some folk prefer both major and minor gridlines, others prefer none or something in between.

-
-

Clean

-

-
-
-

Clear (default)

-

-
-
-

Minimal

-

-
-
-

Plain

-

-
-
-

Scientific

-

-
-
-
-

Spacing

-

Plot margins and space between axes titles and lines etc. is controlled with the spacing parameter. Lower values will make plots more compact, higher values will give them more padding. Compare the plots below where the spacing has been set to 0, 1 and 2 respectively.

-

-

-

-
-
-

Type

-

The type parameter can be set to either inner or outer. When inner, the background colour of a plot will not extend past the plot area. outer will colour the entire plot and background.

-
ggthemr('earth', type = 'inner')
-example_plot
-

-
ggthemr('earth', type = 'outer')
-example_plot
-

-
-
-

Tweaking Themes

-

Squinting at a chart? Low on printer ink? ggthemr includes some methods to tweak charts to make them lighter or darker. Here’s a standard theme:

-
ggthemr('dust')
-example_plot
-

-

Maybe that plot comes out a bit pale looking when you print it. Here’s how you can add a bit more contrast to the swatch:

-
darken_swatch(amount = 0.3)
-example_plot
-

-

The second parameter to darken_swatch() controls the degree to which the colours are made darker. Full list of methods with similar functionality:

-
    -
  • darken_swatch() / lighten_swatch(): darker/lighter swatch colours.
  • -
  • darken_gradient() / lighten_gradient(): darker/lighter gradient colours.
  • -
  • darken_palette() / lighten_palette(): darker/lighter everything.
  • -
-

I’ll add methods to darken/lighten the axes lines and text soon too.

-
-
-

Plot Adjustments

-

Most of the time you’ll probably just want to set the theme and not worry about it. There may be times though where you’ll want to make some small adjustment, or manually change what items appear as what colour in a plot.

-
ggthemr('dust')
-mpg_plot <- ggplot(mpg[mpg$drv != '4', ], aes(factor(cyl), cty, fill = drv)) + 
-  geom_boxplot() + labs(x = 'Cylinders', y = 'City MPG', fill = 'Drive Type') +
-  theme(legend.position = 'bottom')
-mpg_plot
-

-

For some reason you decide you want to change those colours. Front-wheel drive vehicles should be orange. Rear-wheelers should be that red colour. You could change the order of the levels of your fill variable, but you shouldn’t have to do that. You just want to switch those colours but you have no idea what they are. swatch() will give you the colours in the currently active ggthemr palette.

-
swatch()
-
## [1] "#555555" "#db735c" "#EFA86E" "#9A8A76" "#F3C57B" "#7A6752" "#2A91A2"
-## [8] "#87F28A" "#6EDCEF"
-## attr(,"class")
-## [1] "ggthemr_swatch"
-

So you can manually swap the two colours around.

-
to_swap <- swatch()[2:3]
-mpg_plot + scale_fill_manual(values = rev(to_swap))
-

-

Note: the first colour in a swatch is a special one. It is reserved for outlining boxplots, text etc. So that’s why the second and third colours were swapped.

-
-
- - -
- - - - - - - - diff --git a/README.markdown_github b/README.markdown_github new file mode 100644 index 0000000..6d3ff29 --- /dev/null +++ b/README.markdown_github @@ -0,0 +1,306 @@ +- [ggthemr](#ggthemr) + - [Installation](#installation) + - [Usage](#usage) + - [Further Development](#further-development) + - [Palettes](#palettes) + - [flat](#flat) + - [flat dark](#flat-dark) + - [camoflauge](#camoflauge) + - [chalk](#chalk) + - [copper](#copper) + - [dust](#dust) + - [earth](#earth) + - [fresh](#fresh) + - [grape](#grape) + - [grass](#grass) + - [greyscale](#greyscale) + - [light](#light) + - [lilac](#lilac) + - [pale](#pale) + - [sea](#sea) + - [sky](#sky) + - [solarized](#solarized) + - [Custom Palettes](#custom-palettes) + - [Layouts](#layouts) + - [Clean](#clean) + - [Clear (default)](#clear-default) + - [Minimal](#minimal) + - [Plain](#plain) + - [Scientific](#scientific) + - [Spacing](#spacing) + - [Type](#type) + - [Tweaking Themes](#tweaking-themes) + - [Plot Adjustments](#plot-adjustments) + + + ## Error in library(gridExtra): there is no package called 'gridExtra' + +ggthemr +======= + +Themes for ggplot2. The idea of this package is that you can just set the theme and then forget about it. You shouldn't have to change any of your existing code. There are several parts to a theme: + +- Colour palette for the background, axes, gridlines, text etc. +- Layout of axes lines and gridlines. +- Spacing around plot and between elements (i.e. axes titles to axes lines etc). You can set the spacing to determine how compact or spread out a plot is. +- Text size. + +There are a number of preset palettes and layouts, and methods to create your own colour schemes. + +Installation +------------ + +This package is still under development and isn't too stable yet, but can be installed using [devtools](http://cran.r-project.org/web/packages/devtools/index.html). + +``` r +devtools::install_github('cttobin/ggthemr') +``` + +Usage +----- + +To just set the colour scheme: + +``` r +ggthemr('dust') +``` + +That's it. Any ggplot you create from then on will have the theme applied. You can clear the theme and return to ggplot2's default using: + +``` r +ggthemr_reset() +``` + +Further Development +------------------- + +Features on the way: + +- More palettes and layouts. +- Options to control fonts. +- Ability to reset themes back to default. +- Theme modifiers (so you can do things like `plot + no_legend()`, `plot + no_axes()` etc.). + +Palettes +-------- + +The palette determines the colours of everything in a plot including the background, layers, gridlines, title text, axes lines, axes text and axes titles. The *swatch* is the the name given to the set of colours strictly used in styling the geoms/layer elements (e.g. the points in `geom_point()`, bars in `geom_bar()` etc.). At least six colours have been supplied in each palette's swatch. + +There are a wide variety of themes in this package (and more on the way). Some of them serious business... others are delibrately stylish and might not be that good for use in proper publications. + +### flat + +[Base 16](https://github.com/chriskempson/base16) + + ## Error in do.call(grid.arrange, display): object 'grid.arrange' not found + +### flat dark + +[Base 16](https://github.com/chriskempson/base16) + + ## Error in do.call(grid.arrange, display): object 'grid.arrange' not found + +### camoflauge + + ## Error in do.call(grid.arrange, display): object 'grid.arrange' not found + +### chalk + + ## Error in do.call(grid.arrange, display): object 'grid.arrange' not found + +### copper + + ## Error in do.call(grid.arrange, display): object 'grid.arrange' not found + +### dust + + ## Error in do.call(grid.arrange, display): object 'grid.arrange' not found + +### earth + + ## Error in do.call(grid.arrange, display): object 'grid.arrange' not found + +### fresh + + ## Error in do.call(grid.arrange, display): object 'grid.arrange' not found + +### grape + + ## Error in do.call(grid.arrange, display): object 'grid.arrange' not found + +### grass + + ## Error in do.call(grid.arrange, display): object 'grid.arrange' not found + +### greyscale + + ## Error in do.call(grid.arrange, display): object 'grid.arrange' not found + +### light + + ## Error in do.call(grid.arrange, display): object 'grid.arrange' not found + +### lilac + + ## Error in do.call(grid.arrange, display): object 'grid.arrange' not found + +### pale + + ## Error in do.call(grid.arrange, display): object 'grid.arrange' not found + +### sea + + ## Error in do.call(grid.arrange, display): object 'grid.arrange' not found + +### sky + + ## Error in do.call(grid.arrange, display): object 'grid.arrange' not found + +### solarized + + ## Error in do.call(grid.arrange, display): object 'grid.arrange' not found + +Custom Palettes +--------------- + +`define_palette()` lets you make your own themes that can be passed to `ggthemr()` just like any of the palettes above. Here's an example of a (probably ugly) palette using random colours: + +``` r +# Random colours that aren't white. +set.seed(12345) +random_colours <- sample(colors()[-c(1, 253, 361)], 10L) + +ugly <- define_palette( + swatch = random_colours, + gradient = c(lower = random_colours[1L], upper = random_colours[2L]) +) + +ggthemr(ugly) + +example_plot + ggtitle(':(') +``` + +![plot of chunk unnamed-chunk-22](figure/unnamed-chunk-22-1.png) + +You can define all elements of a palette using `define_palette()` including colours for the background, text, axes lines, swatch and gradients. + +Layouts +------- + +The layout of a theme controls the appearance and position of the axes, gridlines and text. Some folk prefer both major and minor gridlines, others prefer none or something in between. + +### Clean + +![plot of chunk unnamed-chunk-23](figure/unnamed-chunk-23-1.png) + +### Clear (default) + +![plot of chunk unnamed-chunk-24](figure/unnamed-chunk-24-1.png) + +### Minimal + +![plot of chunk unnamed-chunk-25](figure/unnamed-chunk-25-1.png) + +### Plain + +![plot of chunk unnamed-chunk-26](figure/unnamed-chunk-26-1.png) + +### Scientific + +![plot of chunk unnamed-chunk-27](figure/unnamed-chunk-27-1.png) + +Spacing +------- + +Plot margins and space between axes titles and lines etc. is controlled with the *spacing* parameter. Lower values will make plots more compact, higher values will give them more padding. Compare the plots below where the spacing has been set to 0, 1 and 2 respectively. + +![plot of chunk unnamed-chunk-28](figure/unnamed-chunk-28-1.png) + +![plot of chunk unnamed-chunk-29](figure/unnamed-chunk-29-1.png) + +![plot of chunk unnamed-chunk-30](figure/unnamed-chunk-30-1.png) + +Type +---- + +The *type* parameter can be set to either *inner* or *outer*. When *inner*, the background colour of a plot will not extend past the plot area. *outer* will colour the entire plot and background. + +``` r +ggthemr('earth', type = 'inner') +example_plot +``` + +![plot of chunk unnamed-chunk-31](figure/unnamed-chunk-31-1.png) + +``` r +ggthemr('earth', type = 'outer') +example_plot +``` + +![plot of chunk unnamed-chunk-32](figure/unnamed-chunk-32-1.png) + +Tweaking Themes +--------------- + +Squinting at a chart? Low on printer ink? ggthemr includes some methods to tweak charts to make them lighter or darker. Here's a standard theme: + +``` r +ggthemr('dust') +example_plot +``` + +![plot of chunk unnamed-chunk-33](figure/unnamed-chunk-33-1.png) + +Maybe that plot comes out a bit pale looking when you print it. Here's how you can add a bit more contrast to the swatch: + +``` r +darken_swatch(amount = 0.3) +example_plot +``` + +![plot of chunk unnamed-chunk-34](figure/unnamed-chunk-34-1.png) + +The second parameter to `darken_swatch()` controls the degree to which the colours are made darker. Full list of methods with similar functionality: + +- `darken_swatch()` / `lighten_swatch()`: darker/lighter swatch colours. +- `darken_gradient()` / `lighten_gradient()`: darker/lighter gradient colours. +- `darken_palette()` / `lighten_palette()`: darker/lighter everything. + +I'll add methods to darken/lighten the axes lines and text soon too. + +Plot Adjustments +---------------- + +Most of the time you'll probably just want to set the theme and not worry about it. There may be times though where you'll want to make some small adjustment, or manually change what items appear as what colour in a plot. + +``` r +ggthemr('dust') +mpg_plot <- ggplot(mpg[mpg$drv != '4', ], aes(factor(cyl), cty, fill = drv)) + + geom_boxplot() + labs(x = 'Cylinders', y = 'City MPG', fill = 'Drive Type') + + theme(legend.position = 'bottom') +mpg_plot +``` + +![plot of chunk unnamed-chunk-35](figure/unnamed-chunk-35-1.png) + +For some reason you decide you want to change those colours. Front-wheel drive vehicles should be orange. Rear-wheelers should be that red colour. You could change the order of the levels of your fill variable, but you shouldn't have to do that. You just want to switch those colours but you have no idea what they are. `swatch()` will give you the colours in the currently active ggthemr palette. + +``` r +swatch() +``` + + ## [1] "#555555" "#db735c" "#EFA86E" "#9A8A76" "#F3C57B" "#7A6752" "#2A91A2" + ## [8] "#87F28A" "#6EDCEF" + ## attr(,"class") + ## [1] "ggthemr_swatch" + +So you can manually swap the two colours around. + +``` r +to_swap <- swatch()[2:3] +mpg_plot + scale_fill_manual(values = rev(to_swap)) +``` + +![plot of chunk unnamed-chunk-37](figure/unnamed-chunk-37-1.png) + +**Note:** the first colour in a swatch is a special one. It is reserved for outlining boxplots, text etc. So that's why the second and third colours were swapped. diff --git a/README.md b/README.md index 5e8e3c6..a863688 100644 --- a/README.md +++ b/README.md @@ -1,143 +1,171 @@ - - +- [ggthemr](#ggthemr) + - [Installation](#installation) + - [Usage](#usage) + - [Further Development](#further-development) + - [Palettes](#palettes) + - [flat](#flat) + - [flat dark](#flat-dark) + - [camoflauge](#camoflauge) + - [chalk](#chalk) + - [copper](#copper) + - [dust](#dust) + - [earth](#earth) + - [fresh](#fresh) + - [grape](#grape) + - [grass](#grass) + - [greyscale](#greyscale) + - [light](#light) + - [lilac](#lilac) + - [pale](#pale) + - [sea](#sea) + - [sky](#sky) + - [solarized](#solarized) + - [Custom Palettes](#custom-palettes) + - [Layouts](#layouts) + - [Clean](#clean) + - [Clear (default)](#clear-default) + - [Minimal](#minimal) + - [Plain](#plain) + - [Scientific](#scientific) + - [Spacing](#spacing) + - [Type](#type) + - [Tweaking Themes](#tweaking-themes) + - [Plot Adjustments](#plot-adjustments) + + ggthemr -======================================================== +======= Themes for ggplot2. The idea of this package is that you can just set the theme and then forget about it. You shouldn't have to change any of your existing code. There are several parts to a theme: -* Colour palette for the background, axes, gridlines, text etc. -* Layout of axes lines and gridlines. -* Spacing around plot and between elements (i.e. axes titles to axes lines etc). You can set the spacing to determine how compact or spread out a plot is. -* Text size. +- Colour palette for the background, axes, gridlines, text etc. +- Layout of axes lines and gridlines. +- Spacing around plot and between elements (i.e. axes titles to axes lines etc). You can set the spacing to determine how compact or spread out a plot is. +- Text size. There are a number of preset palettes and layouts, and methods to create your own colour schemes. - Installation -------------------------- +------------ This package is still under development and isn't too stable yet, but can be installed using [devtools](http://cran.r-project.org/web/packages/devtools/index.html). - -```r -devtools::install_github('ggthemr', 'cttobin') +``` r +devtools::install_github('cttobin/ggthemr') ``` Usage -------------------------- +----- To just set the colour scheme: - -```r +``` r ggthemr('dust') ``` That's it. Any ggplot you create from then on will have the theme applied. You can clear the theme and return to ggplot2's default using: - -```r +``` r ggthemr_reset() ``` - Further Development -------------------------- +------------------- Features on the way: -* More palettes and layouts. -* Options to control fonts. -* Ability to reset themes back to default. -* Theme modifiers (so you can do things like `plot + no_legend()`, `plot + no_axes()` etc.). +- More palettes and layouts. +- Options to control fonts. +- Ability to reset themes back to default. +- Theme modifiers (so you can do things like `plot + no_legend()`, `plot + no_axes()` etc.). Palettes -------------------------- +-------- -The palette determines the colours of everything in a plot including the background, layers, gridlines, title text, axes lines, axes text and axes titles. The *swatch* is the the name given to the set of colours strictly used in styling the geoms/layer elements (e.g. the points in `geom_point()`, bars in `geom_bar()` etc.). At least six colours have been supplied in each palette's swatch. +The palette determines the colours of everything in a plot including the background, layers, gridlines, title text, axes lines, axes text and axes titles. The *swatch* is the the name given to the set of colours strictly used in styling the geoms/layer elements (e.g. the points in `geom_point()`, bars in `geom_bar()` etc.). At least six colours have been supplied in each palette's swatch. -There are a wide variety of themes in this package (and more on the way). Some of them serious business... others are delibrately stylish and might not be that good for use in proper publications. +There are a wide variety of themes in this package (and more on the way). Some of them serious business... others are delibrately stylish and might not be that good for use in proper publications. ### flat [Base 16](https://github.com/chriskempson/base16) - ![plot of chunk unnamed-chunk-5](figure/unnamed-chunk-5-1.png) +![](README_files/figure-markdown_github/unnamed-chunk-5-1.png) ### flat dark [Base 16](https://github.com/chriskempson/base16) - - ![plot of chunk unnamed-chunk-6](figure/unnamed-chunk-6-1.png) + +![](README_files/figure-markdown_github/unnamed-chunk-6-1.png) ### camoflauge - - ![plot of chunk unnamed-chunk-7](figure/unnamed-chunk-7-1.png) - + +![](README_files/figure-markdown_github/unnamed-chunk-7-1.png) + ### chalk - - ![plot of chunk unnamed-chunk-8](figure/unnamed-chunk-8-1.png) - + +![](README_files/figure-markdown_github/unnamed-chunk-8-1.png) + ### copper - - ![plot of chunk unnamed-chunk-9](figure/unnamed-chunk-9-1.png) - + +![](README_files/figure-markdown_github/unnamed-chunk-9-1.png) + ### dust - - ![plot of chunk unnamed-chunk-10](figure/unnamed-chunk-10-1.png) - + +![](README_files/figure-markdown_github/unnamed-chunk-10-1.png) + ### earth - - ![plot of chunk unnamed-chunk-11](figure/unnamed-chunk-11-1.png) - + +![](README_files/figure-markdown_github/unnamed-chunk-11-1.png) + ### fresh - - ![plot of chunk unnamed-chunk-12](figure/unnamed-chunk-12-1.png) - + +![](README_files/figure-markdown_github/unnamed-chunk-12-1.png) + ### grape - - ![plot of chunk unnamed-chunk-13](figure/unnamed-chunk-13-1.png) - + +![](README_files/figure-markdown_github/unnamed-chunk-13-1.png) + ### grass - - ![plot of chunk unnamed-chunk-14](figure/unnamed-chunk-14-1.png) - + +![](README_files/figure-markdown_github/unnamed-chunk-14-1.png) + ### greyscale - - ![plot of chunk unnamed-chunk-15](figure/unnamed-chunk-15-1.png) - + +![](README_files/figure-markdown_github/unnamed-chunk-15-1.png) + ### light - - ![plot of chunk unnamed-chunk-16](figure/unnamed-chunk-16-1.png) - + +![](README_files/figure-markdown_github/unnamed-chunk-16-1.png) + ### lilac - - ![plot of chunk unnamed-chunk-17](figure/unnamed-chunk-17-1.png) - + +![](README_files/figure-markdown_github/unnamed-chunk-17-1.png) + ### pale - - ![plot of chunk unnamed-chunk-18](figure/unnamed-chunk-18-1.png) - + +![](README_files/figure-markdown_github/unnamed-chunk-18-1.png) + ### sea - - ![plot of chunk unnamed-chunk-19](figure/unnamed-chunk-19-1.png) - + +![](README_files/figure-markdown_github/unnamed-chunk-19-1.png) + ### sky - - ![plot of chunk unnamed-chunk-20](figure/unnamed-chunk-20-1.png) - + +![](README_files/figure-markdown_github/unnamed-chunk-20-1.png) + ### solarized - - ![plot of chunk unnamed-chunk-21](figure/unnamed-chunk-21-1.png) - + +![](README_files/figure-markdown_github/unnamed-chunk-21-1.png) + Custom Palettes -------------------------- - -`define_palette()` lets you make your own themes that can be passed to `ggthemr()` just like any of the palettes above. Here's an example of a (probably ugly) palette using random colours: +--------------- +`define_palette()` lets you make your own themes that can be passed to `ggthemr()` just like any of the palettes above. Here's an example of a (probably ugly) palette using random colours: -```r +``` r # Random colours that aren't white. +set.seed(12345) random_colours <- sample(colors()[-c(1, 253, 361)], 10L) ugly <- define_palette( @@ -150,108 +178,100 @@ ggthemr(ugly) example_plot + ggtitle(':(') ``` -![plot of chunk unnamed-chunk-22](figure/unnamed-chunk-22-1.png) - -You can define all elements of a palette using `define_palette()` including colours for the background, text, axes lines, swatch and gradients. +![](README_files/figure-markdown_github/unnamed-chunk-22-1.png) +You can define all elements of a palette using `define_palette()` including colours for the background, text, axes lines, swatch and gradients. Layouts -------------------------- +------- -The layout of a theme controls the appearance and position of the axes, gridlines and text. Some folk prefer both major and minor gridlines, others prefer none or something in between. +The layout of a theme controls the appearance and position of the axes, gridlines and text. Some folk prefer both major and minor gridlines, others prefer none or something in between. ### Clean - - ![plot of chunk unnamed-chunk-23](figure/unnamed-chunk-23-1.png) - + +![](README_files/figure-markdown_github/unnamed-chunk-23-1.png) + ### Clear (default) - - ![plot of chunk unnamed-chunk-24](figure/unnamed-chunk-24-1.png) - + +![](README_files/figure-markdown_github/unnamed-chunk-24-1.png) + ### Minimal - - ![plot of chunk unnamed-chunk-25](figure/unnamed-chunk-25-1.png) + +![](README_files/figure-markdown_github/unnamed-chunk-25-1.png) ### Plain - - ![plot of chunk unnamed-chunk-26](figure/unnamed-chunk-26-1.png) - + +![](README_files/figure-markdown_github/unnamed-chunk-26-1.png) + ### Scientific - - ![plot of chunk unnamed-chunk-27](figure/unnamed-chunk-27-1.png) + +![](README_files/figure-markdown_github/unnamed-chunk-27-1.png) Spacing -------------------------- +------- Plot margins and space between axes titles and lines etc. is controlled with the *spacing* parameter. Lower values will make plots more compact, higher values will give them more padding. Compare the plots below where the spacing has been set to 0, 1 and 2 respectively. -![plot of chunk unnamed-chunk-28](figure/unnamed-chunk-28-1.png) +![](README_files/figure-markdown_github/unnamed-chunk-28-1.png) -![plot of chunk unnamed-chunk-29](figure/unnamed-chunk-29-1.png) +![](README_files/figure-markdown_github/unnamed-chunk-29-1.png) -![plot of chunk unnamed-chunk-30](figure/unnamed-chunk-30-1.png) +![](README_files/figure-markdown_github/unnamed-chunk-30-1.png) Type -------------------------- - -The *type* parameter can be set to either *inner* or *outer*. When *inner*, the background colour of a plot will not extend past the plot area. *outer* will colour the entire plot and background. +---- +The *type* parameter can be set to either *inner* or *outer*. When *inner*, the background colour of a plot will not extend past the plot area. *outer* will colour the entire plot and background. -```r +``` r ggthemr('earth', type = 'inner') example_plot ``` -![plot of chunk unnamed-chunk-31](figure/unnamed-chunk-31-1.png) +![](README_files/figure-markdown_github/unnamed-chunk-31-1.png) - -```r +``` r ggthemr('earth', type = 'outer') example_plot ``` -![plot of chunk unnamed-chunk-32](figure/unnamed-chunk-32-1.png) - +![](README_files/figure-markdown_github/unnamed-chunk-32-1.png) Tweaking Themes -------------------------- +--------------- Squinting at a chart? Low on printer ink? ggthemr includes some methods to tweak charts to make them lighter or darker. Here's a standard theme: - -```r +``` r ggthemr('dust') example_plot ``` -![plot of chunk unnamed-chunk-33](figure/unnamed-chunk-33-1.png) +![](README_files/figure-markdown_github/unnamed-chunk-33-1.png) Maybe that plot comes out a bit pale looking when you print it. Here's how you can add a bit more contrast to the swatch: - -```r +``` r darken_swatch(amount = 0.3) example_plot ``` -![plot of chunk unnamed-chunk-34](figure/unnamed-chunk-34-1.png) +![](README_files/figure-markdown_github/unnamed-chunk-34-1.png) The second parameter to `darken_swatch()` controls the degree to which the colours are made darker. Full list of methods with similar functionality: -* `darken_swatch()` / `lighten_swatch()`: darker/lighter swatch colours. -* `darken_gradient()` / `lighten_gradient()`: darker/lighter gradient colours. -* `darken_palette()` / `lighten_palette()`: darker/lighter everything. - -I'll add methods to darken/lighten the axes lines and text soon too. +- `darken_swatch()` / `lighten_swatch()`: darker/lighter swatch colours. +- `darken_gradient()` / `lighten_gradient()`: darker/lighter gradient colours. +- `darken_palette()` / `lighten_palette()`: darker/lighter everything. +I'll add methods to darken/lighten the axes lines and text soon too. Plot Adjustments -------------------------- +---------------- Most of the time you'll probably just want to set the theme and not worry about it. There may be times though where you'll want to make some small adjustment, or manually change what items appear as what colour in a plot. - -```r +``` r ggthemr('dust') mpg_plot <- ggplot(mpg[mpg$drv != '4', ], aes(factor(cyl), cty, fill = drv)) + geom_boxplot() + labs(x = 'Cylinders', y = 'City MPG', fill = 'Drive Type') + @@ -259,33 +279,26 @@ mpg_plot <- ggplot(mpg[mpg$drv != '4', ], aes(factor(cyl), cty, fill = drv)) + mpg_plot ``` -![plot of chunk unnamed-chunk-35](figure/unnamed-chunk-35-1.png) +![](README_files/figure-markdown_github/unnamed-chunk-35-1.png) +For some reason you decide you want to change those colours. Front-wheel drive vehicles should be orange. Rear-wheelers should be that red colour. You could change the order of the levels of your fill variable, but you shouldn't have to do that. You just want to switch those colours but you have no idea what they are. `swatch()` will give you the colours in the currently active ggthemr palette. -For some reason you decide you want to change those colours. Front-wheel drive vehicles should be orange. Rear-wheelers should be that red colour. You could change the order of the levels of your fill variable, but you shouldn't have to do that. You just want to switch those colours but you have no idea what they are. `swatch()` will give you the colours in the currently active ggthemr palette. - - -```r +``` r swatch() ``` -``` -## [1] "#555555" "#db735c" "#EFA86E" "#9A8A76" "#F3C57B" "#7A6752" "#2A91A2" -## [8] "#87F28A" "#6EDCEF" -## attr(,"class") -## [1] "ggthemr_swatch" -``` + ## [1] "#555555" "#db735c" "#EFA86E" "#9A8A76" "#F3C57B" "#7A6752" "#2A91A2" + ## [8] "#87F28A" "#6EDCEF" + ## attr(,"class") + ## [1] "ggthemr_swatch" So you can manually swap the two colours around. - -```r +``` r to_swap <- swatch()[2:3] mpg_plot + scale_fill_manual(values = rev(to_swap)) ``` -![plot of chunk unnamed-chunk-37](figure/unnamed-chunk-37-1.png) +![](README_files/figure-markdown_github/unnamed-chunk-37-1.png) **Note:** the first colour in a swatch is a special one. It is reserved for outlining boxplots, text etc. So that's why the second and third colours were swapped. - - diff --git a/README_files/figure-markdown_github/unnamed-chunk-10-1.png b/README_files/figure-markdown_github/unnamed-chunk-10-1.png new file mode 100644 index 0000000..9940c7a Binary files /dev/null and b/README_files/figure-markdown_github/unnamed-chunk-10-1.png differ diff --git a/README_files/figure-markdown_github/unnamed-chunk-11-1.png b/README_files/figure-markdown_github/unnamed-chunk-11-1.png new file mode 100644 index 0000000..cfc292e Binary files /dev/null and b/README_files/figure-markdown_github/unnamed-chunk-11-1.png differ diff --git a/README_files/figure-markdown_github/unnamed-chunk-12-1.png b/README_files/figure-markdown_github/unnamed-chunk-12-1.png new file mode 100644 index 0000000..dd70dc0 Binary files /dev/null and b/README_files/figure-markdown_github/unnamed-chunk-12-1.png differ diff --git a/README_files/figure-markdown_github/unnamed-chunk-13-1.png b/README_files/figure-markdown_github/unnamed-chunk-13-1.png new file mode 100644 index 0000000..8c9dd4a Binary files /dev/null and b/README_files/figure-markdown_github/unnamed-chunk-13-1.png differ diff --git a/README_files/figure-markdown_github/unnamed-chunk-14-1.png b/README_files/figure-markdown_github/unnamed-chunk-14-1.png new file mode 100644 index 0000000..a8a848b Binary files /dev/null and b/README_files/figure-markdown_github/unnamed-chunk-14-1.png differ diff --git a/README_files/figure-markdown_github/unnamed-chunk-15-1.png b/README_files/figure-markdown_github/unnamed-chunk-15-1.png new file mode 100644 index 0000000..a450980 Binary files /dev/null and b/README_files/figure-markdown_github/unnamed-chunk-15-1.png differ diff --git a/README_files/figure-markdown_github/unnamed-chunk-16-1.png b/README_files/figure-markdown_github/unnamed-chunk-16-1.png new file mode 100644 index 0000000..9a0f70f Binary files /dev/null and b/README_files/figure-markdown_github/unnamed-chunk-16-1.png differ diff --git a/README_files/figure-markdown_github/unnamed-chunk-17-1.png b/README_files/figure-markdown_github/unnamed-chunk-17-1.png new file mode 100644 index 0000000..39f93ef Binary files /dev/null and b/README_files/figure-markdown_github/unnamed-chunk-17-1.png differ diff --git a/README_files/figure-markdown_github/unnamed-chunk-18-1.png b/README_files/figure-markdown_github/unnamed-chunk-18-1.png new file mode 100644 index 0000000..2a7cb6d Binary files /dev/null and b/README_files/figure-markdown_github/unnamed-chunk-18-1.png differ diff --git a/README_files/figure-markdown_github/unnamed-chunk-19-1.png b/README_files/figure-markdown_github/unnamed-chunk-19-1.png new file mode 100644 index 0000000..6c195ca Binary files /dev/null and b/README_files/figure-markdown_github/unnamed-chunk-19-1.png differ diff --git a/README_files/figure-markdown_github/unnamed-chunk-20-1.png b/README_files/figure-markdown_github/unnamed-chunk-20-1.png new file mode 100644 index 0000000..2e37b69 Binary files /dev/null and b/README_files/figure-markdown_github/unnamed-chunk-20-1.png differ diff --git a/README_files/figure-markdown_github/unnamed-chunk-21-1.png b/README_files/figure-markdown_github/unnamed-chunk-21-1.png new file mode 100644 index 0000000..cc33c78 Binary files /dev/null and b/README_files/figure-markdown_github/unnamed-chunk-21-1.png differ diff --git a/README_files/figure-markdown_github/unnamed-chunk-22-1.png b/README_files/figure-markdown_github/unnamed-chunk-22-1.png new file mode 100644 index 0000000..14596b4 Binary files /dev/null and b/README_files/figure-markdown_github/unnamed-chunk-22-1.png differ diff --git a/README_files/figure-markdown_github/unnamed-chunk-23-1.png b/README_files/figure-markdown_github/unnamed-chunk-23-1.png new file mode 100644 index 0000000..ccc3962 Binary files /dev/null and b/README_files/figure-markdown_github/unnamed-chunk-23-1.png differ diff --git a/README_files/figure-markdown_github/unnamed-chunk-24-1.png b/README_files/figure-markdown_github/unnamed-chunk-24-1.png new file mode 100644 index 0000000..695f0d2 Binary files /dev/null and b/README_files/figure-markdown_github/unnamed-chunk-24-1.png differ diff --git a/README_files/figure-markdown_github/unnamed-chunk-25-1.png b/README_files/figure-markdown_github/unnamed-chunk-25-1.png new file mode 100644 index 0000000..5913e90 Binary files /dev/null and b/README_files/figure-markdown_github/unnamed-chunk-25-1.png differ diff --git a/README_files/figure-markdown_github/unnamed-chunk-26-1.png b/README_files/figure-markdown_github/unnamed-chunk-26-1.png new file mode 100644 index 0000000..130bdd2 Binary files /dev/null and b/README_files/figure-markdown_github/unnamed-chunk-26-1.png differ diff --git a/README_files/figure-markdown_github/unnamed-chunk-27-1.png b/README_files/figure-markdown_github/unnamed-chunk-27-1.png new file mode 100644 index 0000000..c4006cc Binary files /dev/null and b/README_files/figure-markdown_github/unnamed-chunk-27-1.png differ diff --git a/README_files/figure-markdown_github/unnamed-chunk-28-1.png b/README_files/figure-markdown_github/unnamed-chunk-28-1.png new file mode 100644 index 0000000..741e468 Binary files /dev/null and b/README_files/figure-markdown_github/unnamed-chunk-28-1.png differ diff --git a/README_files/figure-markdown_github/unnamed-chunk-29-1.png b/README_files/figure-markdown_github/unnamed-chunk-29-1.png new file mode 100644 index 0000000..f76ae25 Binary files /dev/null and b/README_files/figure-markdown_github/unnamed-chunk-29-1.png differ diff --git a/README_files/figure-markdown_github/unnamed-chunk-30-1.png b/README_files/figure-markdown_github/unnamed-chunk-30-1.png new file mode 100644 index 0000000..9f03364 Binary files /dev/null and b/README_files/figure-markdown_github/unnamed-chunk-30-1.png differ diff --git a/README_files/figure-markdown_github/unnamed-chunk-31-1.png b/README_files/figure-markdown_github/unnamed-chunk-31-1.png new file mode 100644 index 0000000..64e76e5 Binary files /dev/null and b/README_files/figure-markdown_github/unnamed-chunk-31-1.png differ diff --git a/README_files/figure-markdown_github/unnamed-chunk-32-1.png b/README_files/figure-markdown_github/unnamed-chunk-32-1.png new file mode 100644 index 0000000..61809b1 Binary files /dev/null and b/README_files/figure-markdown_github/unnamed-chunk-32-1.png differ diff --git a/README_files/figure-markdown_github/unnamed-chunk-33-1.png b/README_files/figure-markdown_github/unnamed-chunk-33-1.png new file mode 100644 index 0000000..e77e819 Binary files /dev/null and b/README_files/figure-markdown_github/unnamed-chunk-33-1.png differ diff --git a/README_files/figure-markdown_github/unnamed-chunk-34-1.png b/README_files/figure-markdown_github/unnamed-chunk-34-1.png new file mode 100644 index 0000000..b7fe727 Binary files /dev/null and b/README_files/figure-markdown_github/unnamed-chunk-34-1.png differ diff --git a/README_files/figure-markdown_github/unnamed-chunk-35-1.png b/README_files/figure-markdown_github/unnamed-chunk-35-1.png new file mode 100644 index 0000000..8186176 Binary files /dev/null and b/README_files/figure-markdown_github/unnamed-chunk-35-1.png differ diff --git a/README_files/figure-markdown_github/unnamed-chunk-37-1.png b/README_files/figure-markdown_github/unnamed-chunk-37-1.png new file mode 100644 index 0000000..9d7a146 Binary files /dev/null and b/README_files/figure-markdown_github/unnamed-chunk-37-1.png differ diff --git a/README_files/figure-markdown_github/unnamed-chunk-5-1.png b/README_files/figure-markdown_github/unnamed-chunk-5-1.png new file mode 100644 index 0000000..0d3c624 Binary files /dev/null and b/README_files/figure-markdown_github/unnamed-chunk-5-1.png differ diff --git a/README_files/figure-markdown_github/unnamed-chunk-6-1.png b/README_files/figure-markdown_github/unnamed-chunk-6-1.png new file mode 100644 index 0000000..24229a2 Binary files /dev/null and b/README_files/figure-markdown_github/unnamed-chunk-6-1.png differ diff --git a/README_files/figure-markdown_github/unnamed-chunk-7-1.png b/README_files/figure-markdown_github/unnamed-chunk-7-1.png new file mode 100644 index 0000000..ed23604 Binary files /dev/null and b/README_files/figure-markdown_github/unnamed-chunk-7-1.png differ diff --git a/README_files/figure-markdown_github/unnamed-chunk-8-1.png b/README_files/figure-markdown_github/unnamed-chunk-8-1.png new file mode 100644 index 0000000..02c8683 Binary files /dev/null and b/README_files/figure-markdown_github/unnamed-chunk-8-1.png differ diff --git a/README_files/figure-markdown_github/unnamed-chunk-9-1.png b/README_files/figure-markdown_github/unnamed-chunk-9-1.png new file mode 100644 index 0000000..c7c0cb6 Binary files /dev/null and b/README_files/figure-markdown_github/unnamed-chunk-9-1.png differ diff --git a/figure/unnamed-chunk-10-1.png b/figure/unnamed-chunk-10-1.png index 4f5eb0d..2c262a5 100644 Binary files a/figure/unnamed-chunk-10-1.png and b/figure/unnamed-chunk-10-1.png differ diff --git a/figure/unnamed-chunk-11-1.png b/figure/unnamed-chunk-11-1.png index 0ed77d9..68b70e4 100644 Binary files a/figure/unnamed-chunk-11-1.png and b/figure/unnamed-chunk-11-1.png differ diff --git a/figure/unnamed-chunk-12-1.png b/figure/unnamed-chunk-12-1.png index cc59608..48cc9b1 100644 Binary files a/figure/unnamed-chunk-12-1.png and b/figure/unnamed-chunk-12-1.png differ diff --git a/figure/unnamed-chunk-13-1.png b/figure/unnamed-chunk-13-1.png index 7d24038..32ad76e 100644 Binary files a/figure/unnamed-chunk-13-1.png and b/figure/unnamed-chunk-13-1.png differ diff --git a/figure/unnamed-chunk-14-1.png b/figure/unnamed-chunk-14-1.png index 27900a3..183b6cb 100644 Binary files a/figure/unnamed-chunk-14-1.png and b/figure/unnamed-chunk-14-1.png differ diff --git a/figure/unnamed-chunk-15-1.png b/figure/unnamed-chunk-15-1.png index cbbd92f..054cc71 100644 Binary files a/figure/unnamed-chunk-15-1.png and b/figure/unnamed-chunk-15-1.png differ diff --git a/figure/unnamed-chunk-16-1.png b/figure/unnamed-chunk-16-1.png index a18e2f8..4ef57e2 100644 Binary files a/figure/unnamed-chunk-16-1.png and b/figure/unnamed-chunk-16-1.png differ diff --git a/figure/unnamed-chunk-17-1.png b/figure/unnamed-chunk-17-1.png index a370732..5b224d8 100644 Binary files a/figure/unnamed-chunk-17-1.png and b/figure/unnamed-chunk-17-1.png differ diff --git a/figure/unnamed-chunk-18-1.png b/figure/unnamed-chunk-18-1.png index 1f07d9e..0d9af6d 100644 Binary files a/figure/unnamed-chunk-18-1.png and b/figure/unnamed-chunk-18-1.png differ diff --git a/figure/unnamed-chunk-19-1.png b/figure/unnamed-chunk-19-1.png index dd06c01..2181164 100644 Binary files a/figure/unnamed-chunk-19-1.png and b/figure/unnamed-chunk-19-1.png differ diff --git a/figure/unnamed-chunk-20-1.png b/figure/unnamed-chunk-20-1.png index 896b6de..c192119 100644 Binary files a/figure/unnamed-chunk-20-1.png and b/figure/unnamed-chunk-20-1.png differ diff --git a/figure/unnamed-chunk-21-1.png b/figure/unnamed-chunk-21-1.png index 3b4a695..bc06ef8 100644 Binary files a/figure/unnamed-chunk-21-1.png and b/figure/unnamed-chunk-21-1.png differ diff --git a/figure/unnamed-chunk-22-1.png b/figure/unnamed-chunk-22-1.png index ad31a4a..b67477d 100644 Binary files a/figure/unnamed-chunk-22-1.png and b/figure/unnamed-chunk-22-1.png differ diff --git a/figure/unnamed-chunk-23-1.png b/figure/unnamed-chunk-23-1.png index 156657e..71cd347 100644 Binary files a/figure/unnamed-chunk-23-1.png and b/figure/unnamed-chunk-23-1.png differ diff --git a/figure/unnamed-chunk-24-1.png b/figure/unnamed-chunk-24-1.png index 0a40092..89a7c11 100644 Binary files a/figure/unnamed-chunk-24-1.png and b/figure/unnamed-chunk-24-1.png differ diff --git a/figure/unnamed-chunk-25-1.png b/figure/unnamed-chunk-25-1.png index 5ff3d51..2863438 100644 Binary files a/figure/unnamed-chunk-25-1.png and b/figure/unnamed-chunk-25-1.png differ diff --git a/figure/unnamed-chunk-26-1.png b/figure/unnamed-chunk-26-1.png index 398632d..48d842a 100644 Binary files a/figure/unnamed-chunk-26-1.png and b/figure/unnamed-chunk-26-1.png differ diff --git a/figure/unnamed-chunk-27-1.png b/figure/unnamed-chunk-27-1.png index a4729e4..d783c1d 100644 Binary files a/figure/unnamed-chunk-27-1.png and b/figure/unnamed-chunk-27-1.png differ diff --git a/figure/unnamed-chunk-28-1.png b/figure/unnamed-chunk-28-1.png index 46bf214..52059aa 100644 Binary files a/figure/unnamed-chunk-28-1.png and b/figure/unnamed-chunk-28-1.png differ diff --git a/figure/unnamed-chunk-29-1.png b/figure/unnamed-chunk-29-1.png index 21e2ac4..67de74b 100644 Binary files a/figure/unnamed-chunk-29-1.png and b/figure/unnamed-chunk-29-1.png differ diff --git a/figure/unnamed-chunk-30-1.png b/figure/unnamed-chunk-30-1.png index e89f561..c155136 100644 Binary files a/figure/unnamed-chunk-30-1.png and b/figure/unnamed-chunk-30-1.png differ diff --git a/figure/unnamed-chunk-31-1.png b/figure/unnamed-chunk-31-1.png index 098ce91..cf809f6 100644 Binary files a/figure/unnamed-chunk-31-1.png and b/figure/unnamed-chunk-31-1.png differ diff --git a/figure/unnamed-chunk-32-1.png b/figure/unnamed-chunk-32-1.png index d71f16a..a1178a1 100644 Binary files a/figure/unnamed-chunk-32-1.png and b/figure/unnamed-chunk-32-1.png differ diff --git a/figure/unnamed-chunk-33-1.png b/figure/unnamed-chunk-33-1.png index ed629b0..f0babc1 100644 Binary files a/figure/unnamed-chunk-33-1.png and b/figure/unnamed-chunk-33-1.png differ diff --git a/figure/unnamed-chunk-34-1.png b/figure/unnamed-chunk-34-1.png index 3a9b600..9753e97 100644 Binary files a/figure/unnamed-chunk-34-1.png and b/figure/unnamed-chunk-34-1.png differ diff --git a/figure/unnamed-chunk-35-1.png b/figure/unnamed-chunk-35-1.png index a3eccf5..7702d67 100644 Binary files a/figure/unnamed-chunk-35-1.png and b/figure/unnamed-chunk-35-1.png differ diff --git a/figure/unnamed-chunk-37-1.png b/figure/unnamed-chunk-37-1.png index e1524fb..938799b 100644 Binary files a/figure/unnamed-chunk-37-1.png and b/figure/unnamed-chunk-37-1.png differ diff --git a/figure/unnamed-chunk-5-1.png b/figure/unnamed-chunk-5-1.png index e14cadc..37c6ab0 100644 Binary files a/figure/unnamed-chunk-5-1.png and b/figure/unnamed-chunk-5-1.png differ diff --git a/figure/unnamed-chunk-6-1.png b/figure/unnamed-chunk-6-1.png index 6539386..7da2b77 100644 Binary files a/figure/unnamed-chunk-6-1.png and b/figure/unnamed-chunk-6-1.png differ diff --git a/figure/unnamed-chunk-7-1.png b/figure/unnamed-chunk-7-1.png index ca32c6f..2fea63a 100644 Binary files a/figure/unnamed-chunk-7-1.png and b/figure/unnamed-chunk-7-1.png differ diff --git a/figure/unnamed-chunk-8-1.png b/figure/unnamed-chunk-8-1.png index 8327775..638c820 100644 Binary files a/figure/unnamed-chunk-8-1.png and b/figure/unnamed-chunk-8-1.png differ diff --git a/figure/unnamed-chunk-9-1.png b/figure/unnamed-chunk-9-1.png index df4798c..96af963 100644 Binary files a/figure/unnamed-chunk-9-1.png and b/figure/unnamed-chunk-9-1.png differ diff --git a/inst/themes.pdf b/inst/themes.pdf deleted file mode 100644 index 553e78b..0000000 Binary files a/inst/themes.pdf and /dev/null differ diff --git a/man/align_title_left.Rd b/man/align_title_left.Rd index c4be5fd..6943ad4 100644 --- a/man/align_title_left.Rd +++ b/man/align_title_left.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/align_title.R \name{align_title_left} \alias{align_title_left} diff --git a/man/align_title_right.Rd b/man/align_title_right.Rd index 7288c72..1d10a21 100644 --- a/man/align_title_right.Rd +++ b/man/align_title_right.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/align_title.R \name{align_title_right} \alias{align_title_right} diff --git a/man/colour_plot.Rd b/man/colour_plot.Rd index ee405b0..760b9b8 100644 --- a/man/colour_plot.Rd +++ b/man/colour_plot.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/colour_plot.R \name{colour_plot} \alias{colour_plot} @@ -25,6 +25,7 @@ colour_plot(x) Display a chart of colours from a vector of colours or ggthemr object. } \examples{ + colour_plot(c('#14B294', 'coral')) colour_plot(ggthemr('sea')) } diff --git a/man/darken_gradient.Rd b/man/darken_gradient.Rd index fc12338..a84be0e 100644 --- a/man/darken_gradient.Rd +++ b/man/darken_gradient.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/colour_contrast.R \name{darken_gradient} \alias{darken_gradient} diff --git a/man/darken_palette.Rd b/man/darken_palette.Rd index 7b12f54..18da819 100644 --- a/man/darken_palette.Rd +++ b/man/darken_palette.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/colour_contrast.R \name{darken_palette} \alias{darken_palette} diff --git a/man/darken_swatch.Rd b/man/darken_swatch.Rd index a5129a8..fc23213 100644 --- a/man/darken_swatch.Rd +++ b/man/darken_swatch.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/colour_contrast.R \name{darken_swatch} \alias{darken_swatch} diff --git a/man/define_palette.Rd b/man/define_palette.Rd index e8599bb..a9edffe 100644 --- a/man/define_palette.Rd +++ b/man/define_palette.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/define_palette.R \name{define_palette} \alias{define_palette} @@ -24,17 +24,17 @@ define_palette(swatch, gradient, background = "#ffffff", text = c("#444444", Object of type ggthemr_palette that you can pass to ggthemr(). } \description{ -Create a custom palette that can be used by ggthemr. Checks will be carried out to make sure colours are not duplicated and are appropriate (e.g. the text colour should not match the background colour or text will not be visible). +Create a custom palette that can be used by ggthemr. Checks will be carried out to make sure colours are not duplicated and are appropriate (e.g. the text colour should not match the background colour or text will not be visible). Default colours for the background, text, axes lines and gridlines have been provided, but it is recommended that you overwrite these to make a nice theme. } \details{ -The text and axes line colours can both be provided as single -colours or vectors of two colours. If only one colour is provided then -the text and line colours will be identical regardless of the theme -type ("inner" or "outer", see \code{\link{ggthemr}} for more details). -Where your palette doesn't really need different text/line colours for -the theme type than it sufficient to supply only one colour but a +The text and axes line colours can both be provided as single +colours or vectors of two colours. If only one colour is provided then +the text and line colours will be identical regardless of the theme +type ("inner" or "outer", see \code{\link{ggthemr}} for more details). +Where your palette doesn't really need different text/line colours for +the theme type than it sufficient to supply only one colour but a warning will be issued. Vectors supplied for the text and line colours can have elements named "inner" and "outer". In the absence of these names, the first will be assumed to be the "inner" colour, the second will be the "outer" colour. @@ -42,10 +42,10 @@ Vectors supplied for the text and line colours can have elements named "inner" a \examples{ # Create ugly theme with primary colours. ugly <- define_palette( - swatch = c('black', 'red', 'green', 'blue', 'brown', 'purple', 'yellow'), + swatch = c('black', 'red', 'green', 'blue', 'brown', 'purple', 'yellow'), gradient = c(lower = 'red', upper = 'green') ) - + ggthemr(ugly) } \author{ diff --git a/man/get_themr.Rd b/man/get_themr.Rd index 84a5aea..0fdee5e 100644 --- a/man/get_themr.Rd +++ b/man/get_themr.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/ggthemr_current.R \name{get_themr} \alias{get_themr} diff --git a/man/ggthemr.Rd b/man/ggthemr.Rd index 761e2c5..c8232b0 100644 --- a/man/ggthemr.Rd +++ b/man/ggthemr.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/ggthemr-package.r, R/ggthemr.R \docType{package} \name{ggthemr} @@ -33,7 +33,7 @@ ggthemr provides colour schemes and layouts for ggplot2. Set theme to be applied to all subsequent ggplots. } \examples{ -ggthemr('pale', layout = 'scientific', spacing = 2, type = 'inner') + ggthemr('pale', layout = 'scientific', spacing = 2, type = 'inner') } \author{ Ciaran Tobin diff --git a/man/ggthemr_current.Rd b/man/ggthemr_current.Rd index 355fbc4..0ab4bda 100644 --- a/man/ggthemr_current.Rd +++ b/man/ggthemr_current.Rd @@ -1,23 +1,10 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/ggthemr_current.R \docType{data} \name{ggthemr_current} \alias{ggthemr_current} \title{Store Theme} -\format{\preformatted{List of 4 - $ get :function () - ..- attr(*, "srcref")=Class 'srcref' atomic [1:8] 6 11 12 5 11 5 6 12 - .. .. ..- attr(*, "srcfile")=Classes 'srcfilecopy', 'srcfile' - $ set :function (value) - ..- attr(*, "srcref")=Class 'srcref' atomic [1:8] 13 11 16 5 11 5 13 16 - .. .. ..- attr(*, "srcfile")=Classes 'srcfilecopy', 'srcfile' - $ is_set:function () - ..- attr(*, "srcref")=Class 'srcref' atomic [1:8] 17 14 19 5 14 5 17 19 - .. .. ..- attr(*, "srcfile")=Classes 'srcfilecopy', 'srcfile' - $ clear :function () - ..- attr(*, "srcref")=Class 'srcref' atomic [1:8] 20 13 22 5 13 5 20 22 - .. .. ..- attr(*, "srcfile")=Classes 'srcfilecopy', 'srcfile' -}} +\format{An object of class \code{list} of length 4.} \usage{ ggthemr_current } diff --git a/man/ggthemr_reset.Rd b/man/ggthemr_reset.Rd index 4c2772e..d3cbd09 100644 --- a/man/ggthemr_reset.Rd +++ b/man/ggthemr_reset.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/ggthemr_reset.R \name{ggthemr_reset} \alias{ggthemr_reset} diff --git a/man/is_colour.Rd b/man/is_colour.Rd index c312c58..1b441e6 100644 --- a/man/is_colour.Rd +++ b/man/is_colour.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/is_colour.R \name{is_colour} \alias{is_colour} diff --git a/man/is_ggthemr.Rd b/man/is_ggthemr.Rd index 11cbedc..9a17c73 100644 --- a/man/is_ggthemr.Rd +++ b/man/is_ggthemr.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/is_ggthemr.R \name{is_ggthemr} \alias{is_ggthemr} diff --git a/man/legend_position.Rd b/man/legend_position.Rd index bd76fda..cf98c75 100644 --- a/man/legend_position.Rd +++ b/man/legend_position.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/move_legend.R \name{legend_bottom} \alias{legend_bottom} diff --git a/man/lighten_gradient.Rd b/man/lighten_gradient.Rd index 69fb390..e190a7b 100644 --- a/man/lighten_gradient.Rd +++ b/man/lighten_gradient.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/colour_contrast.R \name{lighten_gradient} \alias{lighten_gradient} diff --git a/man/lighten_palette.Rd b/man/lighten_palette.Rd index 073e61b..b2a1314 100644 --- a/man/lighten_palette.Rd +++ b/man/lighten_palette.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/colour_contrast.R \name{lighten_palette} \alias{lighten_palette} diff --git a/man/lighten_swatch.Rd b/man/lighten_swatch.Rd index b5138ec..529fd51 100644 --- a/man/lighten_swatch.Rd +++ b/man/lighten_swatch.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/colour_contrast.R \name{lighten_swatch} \alias{lighten_swatch} diff --git a/man/move_legend.Rd b/man/move_legend.Rd index abe192d..eb4cb7a 100644 --- a/man/move_legend.Rd +++ b/man/move_legend.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/move_legend.R \name{move_legend} \alias{move_legend} diff --git a/man/no_axes.Rd b/man/no_axes.Rd index 238a1df..087e36f 100644 --- a/man/no_axes.Rd +++ b/man/no_axes.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/no_axes.R \name{no_axes} \alias{no_axes} diff --git a/man/no_axes_titles.Rd b/man/no_axes_titles.Rd index 8ded86a..0bc7093 100644 --- a/man/no_axes_titles.Rd +++ b/man/no_axes_titles.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/no_axes.R \name{no_axes_titles} \alias{no_axes_titles} @@ -7,7 +7,7 @@ no_axes_titles() } \description{ -Remove ggplot2 axes titles +Do not show titles for all axes } \author{ Ciaran Tobin diff --git a/man/no_gridlines.Rd b/man/no_gridlines.Rd index 9115a5a..37efab0 100644 --- a/man/no_gridlines.Rd +++ b/man/no_gridlines.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/no_gridlines.R \name{no_gridlines} \alias{no_gridlines} diff --git a/man/no_legend.Rd b/man/no_legend.Rd index bec6bcf..c122ace 100644 --- a/man/no_legend.Rd +++ b/man/no_legend.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/no_legend.R \name{no_legend} \alias{no_legend} diff --git a/man/no_legend_title.Rd b/man/no_legend_title.Rd index 8962ed3..fbfe845 100644 --- a/man/no_legend_title.Rd +++ b/man/no_legend_title.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/no_legend_title.R \name{no_legend_title} \alias{no_legend_title} diff --git a/man/no_major_gridlines.Rd b/man/no_major_gridlines.Rd index fa8b0e4..b576be9 100644 --- a/man/no_major_gridlines.Rd +++ b/man/no_major_gridlines.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/no_gridlines.R \name{no_major_gridlines} \alias{no_major_gridlines} @@ -7,6 +7,6 @@ no_major_gridlines() } \description{ -Remove major gridlines +Do not show major gridlines } diff --git a/man/no_major_x_gridlines.Rd b/man/no_major_x_gridlines.Rd index c2246a8..667b45a 100644 --- a/man/no_major_x_gridlines.Rd +++ b/man/no_major_x_gridlines.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/no_gridlines.R \name{no_major_x_gridlines} \alias{no_major_x_gridlines} @@ -7,6 +7,6 @@ no_major_x_gridlines() } \description{ -Remove major x gridlines +Do not show major gridlines for x-axis } diff --git a/man/no_major_y_gridlines.Rd b/man/no_major_y_gridlines.Rd index 5f90eda..b57fc79 100644 --- a/man/no_major_y_gridlines.Rd +++ b/man/no_major_y_gridlines.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/no_gridlines.R \name{no_major_y_gridlines} \alias{no_major_y_gridlines} @@ -7,6 +7,6 @@ no_major_y_gridlines() } \description{ -Remove major y gridlines +Do not show major gridlines for y-axis } diff --git a/man/no_minor_gridlines.Rd b/man/no_minor_gridlines.Rd index bf72b6e..38b0803 100644 --- a/man/no_minor_gridlines.Rd +++ b/man/no_minor_gridlines.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/no_gridlines.R \name{no_minor_gridlines} \alias{no_minor_gridlines} @@ -7,6 +7,6 @@ no_minor_gridlines() } \description{ -Remove minor gridlines +Do not show minor gridlines } diff --git a/man/no_minor_x_gridlines.Rd b/man/no_minor_x_gridlines.Rd index c46b4f2..a2a1fa9 100644 --- a/man/no_minor_x_gridlines.Rd +++ b/man/no_minor_x_gridlines.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/no_gridlines.R \name{no_minor_x_gridlines} \alias{no_minor_x_gridlines} @@ -7,6 +7,6 @@ no_minor_x_gridlines() } \description{ -Remove minor x gridlines +Do not show minor gridlines for x-axis } diff --git a/man/no_minor_y_gridlines.Rd b/man/no_minor_y_gridlines.Rd index 75b7c08..0552d07 100644 --- a/man/no_minor_y_gridlines.Rd +++ b/man/no_minor_y_gridlines.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/no_gridlines.R \name{no_minor_y_gridlines} \alias{no_minor_y_gridlines} @@ -7,6 +7,6 @@ no_minor_y_gridlines() } \description{ -Remove minor y gridlines +Do not show minor gridlines for y-axis } diff --git a/man/no_ticks.Rd b/man/no_ticks.Rd index 117b545..00f3f48 100644 --- a/man/no_ticks.Rd +++ b/man/no_ticks.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/no_axes.R \name{no_ticks} \alias{no_ticks} @@ -7,7 +7,7 @@ no_ticks() } \description{ -Remove ggplot2 tick marks +Do not show tick marks for all axes } \author{ Ciaran Tobin diff --git a/man/no_title.Rd b/man/no_title.Rd index d20c794..0d9680a 100644 --- a/man/no_title.Rd +++ b/man/no_title.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/no_title.R \name{no_title} \alias{no_title} @@ -7,7 +7,7 @@ no_title() } \description{ -Remove ggplot2 title +Remove the plot title } \author{ Ciaran Tobin diff --git a/man/no_x_axis.Rd b/man/no_x_axis.Rd index 690b136..dd6fb21 100644 --- a/man/no_x_axis.Rd +++ b/man/no_x_axis.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/no_axes.R \name{no_x_axis} \alias{no_x_axis} diff --git a/man/no_x_gridlines.Rd b/man/no_x_gridlines.Rd index bfabf89..2c3f018 100644 --- a/man/no_x_gridlines.Rd +++ b/man/no_x_gridlines.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/no_gridlines.R \name{no_x_gridlines} \alias{no_vertical_gridlines} @@ -12,10 +12,6 @@ no_vertical_gridlines() \description{ Remove all major and minor vertical gridlines from a ggplot2 plot or theme. } -\section{Functions}{ -\itemize{ -\item \code{no_vertical_gridlines}: -}} \author{ Ciaran Tobin } diff --git a/man/no_x_line.Rd b/man/no_x_line.Rd index db6de06..958f60a 100644 --- a/man/no_x_line.Rd +++ b/man/no_x_line.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/no_axes.R \name{no_x_line} \alias{no_x_line} @@ -7,7 +7,7 @@ no_x_line() } \description{ -Remove ggplot2 x-axis line +Do not show x-axis line } \author{ Ciaran Tobin diff --git a/man/no_x_text.Rd b/man/no_x_text.Rd index 0f52933..e63e32b 100644 --- a/man/no_x_text.Rd +++ b/man/no_x_text.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/no_axes.R \name{no_x_text} \alias{no_x_text} @@ -7,7 +7,7 @@ no_x_text() } \description{ -Remove ggplot2 x-axis text/labels +Do not show x-axis text/labels } \author{ Ciaran Tobin diff --git a/man/no_x_ticks.Rd b/man/no_x_ticks.Rd index 1631264..e59c3d2 100644 --- a/man/no_x_ticks.Rd +++ b/man/no_x_ticks.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/no_axes.R \name{no_x_ticks} \alias{no_x_ticks} @@ -7,7 +7,7 @@ no_x_ticks() } \description{ -Remove ggplot2 x-axis tick marks +Do not show tick marks for x-axis } \author{ Ciaran Tobin diff --git a/man/no_x_title.Rd b/man/no_x_title.Rd index 4dcbb06..6cc951e 100644 --- a/man/no_x_title.Rd +++ b/man/no_x_title.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/no_axes.R \name{no_x_title} \alias{no_x_title} @@ -7,7 +7,7 @@ no_x_title() } \description{ -Remove ggplot2 x-axis titles +Do not show x-axis title } \author{ Ciaran Tobin diff --git a/man/no_y_axis.Rd b/man/no_y_axis.Rd index 720564d..7e1d41f 100644 --- a/man/no_y_axis.Rd +++ b/man/no_y_axis.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/no_axes.R \name{no_y_axis} \alias{no_y_axis} diff --git a/man/no_y_gridlines.Rd b/man/no_y_gridlines.Rd index 5910467..0fff3f8 100644 --- a/man/no_y_gridlines.Rd +++ b/man/no_y_gridlines.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/no_gridlines.R \name{no_y_gridlines} \alias{no_horizontal_gridlines} @@ -12,10 +12,6 @@ no_horizontal_gridlines() \description{ Remove all major and minor horizontal gridlines from a ggplot2 plot or theme. } -\section{Functions}{ -\itemize{ -\item \code{no_horizontal_gridlines}: -}} \author{ Ciaran Tobin } diff --git a/man/no_y_line.Rd b/man/no_y_line.Rd index 285d43d..d9cf146 100644 --- a/man/no_y_line.Rd +++ b/man/no_y_line.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/no_axes.R \name{no_y_line} \alias{no_y_line} @@ -7,7 +7,7 @@ no_y_line() } \description{ -Remove ggplot2 y-axis line +Do not show y-axis line } \author{ Ciaran Tobin diff --git a/man/no_y_text.Rd b/man/no_y_text.Rd index 7141414..e73d99f 100644 --- a/man/no_y_text.Rd +++ b/man/no_y_text.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/no_axes.R \name{no_y_text} \alias{no_y_text} @@ -7,7 +7,7 @@ no_y_text() } \description{ -Remove ggplot2 y-axis text/labels +Do not show y-axis text/labels } \author{ Ciaran Tobin diff --git a/man/no_y_ticks.Rd b/man/no_y_ticks.Rd index e11b892..e993f56 100644 --- a/man/no_y_ticks.Rd +++ b/man/no_y_ticks.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/no_axes.R \name{no_y_ticks} \alias{no_y_ticks} @@ -7,7 +7,7 @@ no_y_ticks() } \description{ -Remove ggplot2 y-axis tick marks +Do not show tick marks for y-axis } \author{ Ciaran Tobin diff --git a/man/no_y_title.Rd b/man/no_y_title.Rd index de47bd1..9b74f98 100644 --- a/man/no_y_title.Rd +++ b/man/no_y_title.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/no_axes.R \name{no_y_title} \alias{no_y_title} @@ -7,7 +7,7 @@ no_y_title() } \description{ -Remove ggplot2 y-axis titles +Do not show y-axis title } \author{ Ciaran Tobin diff --git a/man/plot.ggthemr.Rd b/man/plot.ggthemr.Rd index 60c1c83..4d00ac2 100644 --- a/man/plot.ggthemr.Rd +++ b/man/plot.ggthemr.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/plot.R \name{plot.ggthemr} \alias{plot.ggthemr} diff --git a/man/plot.ggthemr_palette.Rd b/man/plot.ggthemr_palette.Rd index 8a91f4a..217741c 100644 --- a/man/plot.ggthemr_palette.Rd +++ b/man/plot.ggthemr_palette.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/plot.R \name{plot.ggthemr_palette} \alias{plot.ggthemr_palette} diff --git a/man/plot.ggthemr_swatch.Rd b/man/plot.ggthemr_swatch.Rd index 1dbd3ea..577aac3 100644 --- a/man/plot.ggthemr_swatch.Rd +++ b/man/plot.ggthemr_swatch.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/plot.R \name{plot.ggthemr_swatch} \alias{plot.ggthemr_swatch} diff --git a/man/random_swatch_colour.Rd b/man/random_swatch_colour.Rd index e92d452..f6115e6 100644 --- a/man/random_swatch_colour.Rd +++ b/man/random_swatch_colour.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/random_swatch_colour.R \name{random_swatch_colour} \alias{random_swatch_colour} @@ -17,11 +17,11 @@ The first colour of the swatch will never be returned as this is a special value } \examples{ ggthemr('dust') -ggplot(diamonds, aes(carat, price)) + +ggplot(diamonds, aes(carat, price)) + geom_point(colour = random_swatch_colour()) colorem <- random_swatch_colour() -ggplot(diamonds, aes(color, price)) + +ggplot(diamonds, aes(color, price)) + geom_boxplot(fill = colorem, outlier.colour = colorem) } \author{ diff --git a/man/reverse_gradient.Rd b/man/reverse_gradient.Rd index 08b47c8..30a35c3 100644 --- a/man/reverse_gradient.Rd +++ b/man/reverse_gradient.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/reverse_gradient.R \name{reverse_gradient} \alias{reverse_gradient} diff --git a/man/rotate_axes_text.Rd b/man/rotate_axes_text.Rd index f85ccd0..44b33c5 100644 --- a/man/rotate_axes_text.Rd +++ b/man/rotate_axes_text.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rotate_labels.R \name{rotate_axes_text} \alias{rotate_axes_text} diff --git a/man/rotate_x_text.Rd b/man/rotate_x_text.Rd index 3fc4ea0..3480e35 100644 --- a/man/rotate_x_text.Rd +++ b/man/rotate_x_text.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rotate_labels.R \name{rotate_x_text} \alias{rotate_x_text} diff --git a/man/rotate_y_text.Rd b/man/rotate_y_text.Rd index 348a32b..9c1b89e 100644 --- a/man/rotate_y_text.Rd +++ b/man/rotate_y_text.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rotate_labels.R \name{rotate_y_text} \alias{rotate_y_text} diff --git a/man/set_swatch.Rd b/man/set_swatch.Rd index 6150b9a..6969555 100644 --- a/man/set_swatch.Rd +++ b/man/set_swatch.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/set_swatch.R \name{set_swatch} \alias{set_swatch} @@ -11,5 +11,7 @@ set_swatch(swatch_colours) } \description{ Edit an existing theme's swatch. The swatch contains the main colours used in a ggplot outside of the colours for the title, axes text, axes lines, gridlines, background etc. + +The first colour of the swatch is separate from the others. It is used in special cases e.g. the outline colour for geom_boxplot(). This colour should have good contrast with at least the second colour of the swatch. } diff --git a/man/set_themr.Rd b/man/set_themr.Rd index 34e0d01..cb7c6ca 100644 --- a/man/set_themr.Rd +++ b/man/set_themr.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/ggthemr_current.R \name{set_themr} \alias{set_themr} diff --git a/man/shuffle_swatch.Rd b/man/shuffle_swatch.Rd index fd41c43..b851d09 100644 --- a/man/shuffle_swatch.Rd +++ b/man/shuffle_swatch.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/shuffle_swatch.R \name{shuffle_swatch} \alias{shuffle_swatch} diff --git a/man/swatch.Rd b/man/swatch.Rd index 470b9e2..e8d6c18 100644 --- a/man/swatch.Rd +++ b/man/swatch.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/swatch.R \name{swatch} \alias{swatch} diff --git a/misc/base16.R b/misc/base16.R new file mode 100644 index 0000000..e17041f --- /dev/null +++ b/misc/base16.R @@ -0,0 +1,65 @@ +library(stringr) + +(function () { + + # List of theme files. + themes_url <- 'https://github.com/chriskempson/base16-builder/tree/master/schemes' + + # Download themes. + themes_list <- RCurl::getURL(themes_url) + + # Pull out the theme file names. + themes <- unique(str_match_all(themes_list, '[a-z0-9\\-]*\\.yml')[[1L]]) + + getFromPalette <- function (palette) + function (...) + paste0('#', unlist(palette[as.character(list(...))], FALSE, FALSE)) + + get_theme <- function (name) { + + # Download the theme file. + url <- paste0('https://raw.githubusercontent.com/chriskempson/base16-builder/master/schemes/', name) + raw <- RCurl::getURL(url) + + # Extract the colour names and values. + colours <- unlist(str_extract_all(raw, '([a-fA-F0-9]{6})')) + names(colours) <- unlist(str_extract_all(raw, 'base0[0-9A-F]')) + + # Getter function by name. + gp <- getFromPalette(colours) + + # Palette name. + title <- str_replace(str_match(name, '([a-z0-9 \\-]*)\\.yml')[, 2], '-', ' ') + + # The Base16 default is called 'default'. Have to rename that. + if (title == 'default') title <- 'base16' + + tryCatch({ + light_theme <- define_palette(swatch = c(gp('base02'), theme_swatch), + background = gp('base07'), + line = gp('base05', 'base05'), + text = gp('base02', 'base03'), + gridline = gp('base06'), + gradient = gp('base0A', 'base08')) + + dark_theme <- define_palette(swatch = c(gp('base07'), theme_swatch), + background = gp('base00'), + line = gp('base02', 'base02'), + text = gp('base03', 'base07'), + gridline = gp('base03'), + gradient = gp('base0A', 'base08')) + + # Make a dark and light palette. + setNames(list(light_theme, dark_theme), paste(title, c('light', 'dark'))) + + }, error = function (e) NULL) + + } + + # Generate a dark and light palette for every theme. + palettes <- unlist(lapply(themes, get_theme), FALSE) + + # Save palettes. + dump('palettes', 'R/palettes_base16.R') + +})() diff --git a/misc/build.R b/misc/build.R new file mode 100644 index 0000000..469e794 --- /dev/null +++ b/misc/build.R @@ -0,0 +1,20 @@ +library(devtools) +library(knitr) +load_all('../') +ggthemr('earth') +preview_theme() +build('pre-build', 'builds') +install.packages('builds/ggthemr_1.0.2.tar.gz', repos=NULL, type='source') + +setwd('../') +knit('README.Rmd', 'README.md') +setwd('misc/') + +ggplot(data.frame()) + +ggthemr_reset() +ggplot(diamonds, aes(price, fill = factor(cut))) + + geom_histogram(binwidth = 850) + + xlab('Price (USD)') + + ylab('Count') + + scale_x_continuous(label = function(x) paste0(x / 1000, 'k')) \ No newline at end of file diff --git a/misc/build.txt b/misc/build.txt new file mode 100644 index 0000000..27688c3 --- /dev/null +++ b/misc/build.txt @@ -0,0 +1,396 @@ +Updating ggthemr documentation +Loading ggthemr +Writing NAMESPACE +Warning: @inheritParams: can't find topic rotate_x_labels +Writing align_title_left.Rd +Writing align_title_right.Rd +Writing darken_swatch.Rd +Writing lighten_swatch.Rd +Writing darken_gradient.Rd +Writing lighten_gradient.Rd +Writing darken_palette.Rd +Writing lighten_palette.Rd +Writing colour_plot.Rd +Writing define_palette.Rd +Writing ggthemr.Rd +Writing ggthemr_current.Rd +Writing get_themr.Rd +Writing set_themr.Rd +Writing ggthemr_reset.Rd +Writing is_colour.Rd +Writing is_ggthemr.Rd +Writing move_legend.Rd +Writing legend_position.Rd +Writing no_axes.Rd +Writing no_x_axis.Rd +Writing no_y_axis.Rd +Writing no_x_line.Rd +Writing no_y_line.Rd +Writing no_x_text.Rd +Writing no_y_text.Rd +Writing no_ticks.Rd +Writing no_x_ticks.Rd +Writing no_y_ticks.Rd +Writing no_axes_titles.Rd +Writing no_x_title.Rd +Writing no_y_title.Rd +Writing no_gridlines.Rd +Writing no_x_gridlines.Rd +Writing no_y_gridlines.Rd +Writing no_legend.Rd +Writing no_legend_title.Rd +Writing no_title.Rd +Writing plot.ggthemr.Rd +Writing plot.ggthemr_palette.Rd +Writing plot.ggthemr_swatch.Rd +Writing random_swatch_colour.Rd +Writing reverse_gradient.Rd +Writing rotate_axes_text.Rd +Writing rotate_x_text.Rd +Writing rotate_y_text.Rd +Writing set_swatch.Rd +Writing shuffle_swatch.Rd +Writing swatch.Rd +'/Library/Frameworks/R.framework/Resources/bin/R' --vanilla CMD build '/Users/tobin/Documents/ggthemr' \ + --no-manual --no-resave-data + +* checking for file ‘/Users/tobin/Documents/ggthemr/DESCRIPTION’ ... OK +* preparing ‘ggthemr’: +* checking DESCRIPTION meta-information ... OK +* checking for LF line-endings in source and make files +* checking for empty or unneeded directories +* building ‘ggthemr_1.0.0.tar.gz’ + +pdflatex not found! Not building PDF manual or vignettes. +If you are planning to release this package, please run a check with manual and vignettes beforehand. + +'/Library/Frameworks/R.framework/Resources/bin/R' --vanilla CMD check \ + '/var/folders/j9/br0cs2nn5mbgq8n1j22hqrc80000gn/T//RtmpPN6yJn/ggthemr_1.0.0.tar.gz' --timings \ + --no-build-vignettes --no-manual + +* using log directory ‘/private/var/folders/j9/br0cs2nn5mbgq8n1j22hqrc80000gn/T/RtmpPN6yJn/ggthemr.Rcheck’ +* using R version 3.1.2 (2014-10-31) +* using platform: x86_64-apple-darwin13.4.0 (64-bit) +* using session charset: UTF-8 +* using option ‘--no-build-vignettes’ +* checking for file ‘ggthemr/DESCRIPTION’ ... OK +* this is package ‘ggthemr’ version ‘1.0.0’ +* checking package namespace information ... OK +* checking package dependencies ... OK +* checking if this is a source package ... OK +* checking if there is a namespace ... OK +* checking for executable files ... OK +* checking for hidden files and directories ... OK +* checking for portable file names ... OK +* checking for sufficient/correct file permissions ... OK +* checking whether package ‘ggthemr’ can be installed ... OK +* checking installed package size ... OK +* checking package directory ... OK +* checking DESCRIPTION meta-information ... NOTE +License components which are templates and need '+ file LICENSE': + MIT License +* checking top-level files ... NOTE +Non-standard files/directories found at top level: + ‘README.Rmd’ ‘README.html’ ‘figure’ ‘misc’ +* checking for left-over files ... OK +* checking index information ... OK +* checking package subdirectories ... OK +* checking R files for non-ASCII characters ... OK +* checking R files for syntax errors ... OK +* checking whether the package can be loaded ... OK +* checking whether the package can be loaded with stated dependencies ... OK +* checking whether the package can be unloaded cleanly ... OK +* checking whether the namespace can be loaded with stated dependencies ... OK +* checking whether the namespace can be unloaded cleanly ... OK +* checking dependencies in R code ... WARNING +'::' or ':::' imports not declared from: + ‘gridExtra’ ‘scales’ +'library' or 'require' call to ‘ggplot2’ which was already attached by Depends. + Please remove these calls from your code. +Packages in Depends field not imported from: + ‘ggplot2’ ‘grid’ + These packages need to be imported from (in the NAMESPACE file) + for when this namespace is loaded but not attached. +See the information on DESCRIPTION files in the chapter ‘Creating R +packages’ of the ‘Writing R Extensions’ manual. +* checking S3 generic/method consistency ... WARNING +colour_plot: + function(x, ...) +colour_plot.character: + function(x) + +colour_plot: + function(x, ...) +colour_plot.ggthemr: + function(x) + +colour_plot: + function(x, ...) +colour_plot.ggthemr_palette: + function(x) + +colour_plot: + function(x, ...) +colour_plot.ggthemr_swatch: + function(x) + +plot: + function(x, ...) +plot.ggthemr_palette: + function(x) + +plot: + function(x, ...) +plot.ggthemr_swatch: + function(x) + +See section ‘Generic functions and methods’ of the ‘Writing R +Extensions’ manual. +* checking replacement functions ... OK +* checking foreign function calls ... OK +* checking R code for possible problems ... NOTE +align_title_left: no visible global function definition for ‘theme’ +align_title_left: no visible global function definition for + ‘element_text’ +align_title_right: no visible global function definition for ‘theme’ +align_title_right: no visible global function definition for + ‘element_text’ +colour_plot.ggthemr: possible error in swatch(x): unused argument (x) +colour_plot.ggthemr_palette: possible error in swatch(x): unused + argument (x) +ggthemr: no visible binding for global variable ‘inner’ +move_legend: no visible global function definition for ‘theme’ +no_axes: no visible global function definition for ‘theme’ +no_axes: no visible global function definition for ‘element_blank’ +no_axes_titles: no visible global function definition for ‘theme’ +no_axes_titles: no visible global function definition for + ‘element_blank’ +no_gridlines: no visible global function definition for ‘theme’ +no_gridlines: no visible global function definition for ‘element_blank’ +no_horizontal_gridlines: no visible global function definition for + ‘theme’ +no_horizontal_gridlines: no visible global function definition for + ‘element_blank’ +no_legend_title: no visible global function definition for ‘theme’ +no_legend_title: no visible global function definition for + ‘element_blank’ +no_major_gridlines: no visible global function definition for ‘theme’ +no_major_gridlines: no visible global function definition for + ‘element_blank’ +no_major_x_gridlines: no visible global function definition for ‘theme’ +no_major_x_gridlines: no visible global function definition for + ‘element_blank’ +no_major_y_gridlines: no visible global function definition for ‘theme’ +no_major_y_gridlines: no visible global function definition for + ‘element_blank’ +no_minor_gridlines: no visible global function definition for ‘theme’ +no_minor_gridlines: no visible global function definition for + ‘element_blank’ +no_minor_x_gridlines: no visible global function definition for ‘theme’ +no_minor_x_gridlines: no visible global function definition for + ‘element_blank’ +no_minor_y_gridlines: no visible global function definition for ‘theme’ +no_minor_y_gridlines: no visible global function definition for + ‘element_blank’ +no_ticks: no visible global function definition for ‘theme’ +no_ticks: no visible global function definition for ‘element_blank’ +no_title: no visible global function definition for ‘theme’ +no_title: no visible global function definition for ‘element_text’ +no_vertical_gridlines: no visible global function definition for + ‘theme’ +no_vertical_gridlines: no visible global function definition for + ‘element_blank’ +no_x_axis: no visible global function definition for ‘theme’ +no_x_axis: no visible global function definition for ‘element_blank’ +no_x_gridlines: no visible global function definition for ‘theme’ +no_x_gridlines: no visible global function definition for + ‘element_blank’ +no_x_line: no visible global function definition for ‘theme’ +no_x_line: no visible global function definition for ‘element_blank’ +no_x_text: no visible global function definition for ‘theme’ +no_x_text: no visible global function definition for ‘element_blank’ +no_x_ticks: no visible global function definition for ‘theme’ +no_x_ticks: no visible global function definition for ‘element_blank’ +no_x_title: no visible global function definition for ‘theme’ +no_x_title: no visible global function definition for ‘element_blank’ +no_y_axis: no visible global function definition for ‘theme’ +no_y_axis: no visible global function definition for ‘element_blank’ +no_y_gridlines: no visible global function definition for ‘theme’ +no_y_gridlines: no visible global function definition for + ‘element_blank’ +no_y_line: no visible global function definition for ‘theme’ +no_y_line: no visible global function definition for ‘element_blank’ +no_y_text: no visible global function definition for ‘theme’ +no_y_text: no visible global function definition for ‘element_blank’ +no_y_ticks: no visible global function definition for ‘theme’ +no_y_ticks: no visible global function definition for ‘element_blank’ +no_y_title: no visible global function definition for ‘theme’ +no_y_title: no visible global function definition for ‘element_blank’ +plot_colours: no visible global function definition for ‘ggplot’ +plot_colours: no visible global function definition for ‘aes’ +plot_colours: no visible binding for global variable ‘Colours’ +plot_colours: no visible global function definition for ‘geom_tile’ +plot_colours: no visible global function definition for + ‘scale_fill_manual’ +plot_colours: no visible global function definition for ‘geom_text’ +plot_colours: no visible global function definition for ‘theme’ +plot_colours: no visible global function definition for ‘element_blank’ +plot_colours: no visible global function definition for ‘element_rect’ +preview_layout: no visible global function definition for ‘ggplot’ +preview_layout: no visible global function definition for ‘aes’ +preview_layout: no visible binding for global variable ‘x’ +preview_layout: no visible binding for global variable ‘y’ +preview_layout: no visible global function definition for ‘geom_blank’ +preview_layout: no visible global function definition for + ‘scale_y_continuous’ +preview_layout: no visible global function definition for ‘labs’ +preview_theme: no visible binding for global variable ‘Users’ +preview_theme: no visible global function definition for ‘ggplot’ +preview_theme: no visible global function definition for ‘aes’ +preview_theme: no visible binding for global variable ‘Minute’ +preview_theme: no visible binding for global variable ‘Measure’ +preview_theme: no visible global function definition for ‘geom_line’ +preview_theme: no visible global function definition for ‘geom_point’ +preview_theme: no visible global function definition for + ‘scale_shape_manual’ +preview_theme: no visible global function definition for + ‘scale_x_discrete’ +preview_theme: no visible global function definition for ‘theme’ +preview_theme: no visible global function definition for + ‘scale_y_continuous’ +preview_theme: no visible binding for global variable ‘diamonds’ +preview_theme: no visible binding for global variable ‘price’ +preview_theme: no visible global function definition for + ‘geom_histogram’ +preview_theme: no visible global function definition for ‘xlab’ +preview_theme: no visible global function definition for ‘ylab’ +preview_theme: no visible global function definition for + ‘scale_x_continuous’ +preview_theme: no visible binding for global variable ‘Year’ +preview_theme: no visible binding for global variable ‘Deaths’ +preview_theme: no visible global function definition for ‘geom_boxplot’ +preview_theme: no visible binding for global variable ‘mpg’ +preview_theme: no visible binding for global variable ‘cyl’ +preview_theme: no visible global function definition for ‘geom_density’ +preview_theme: no visible global function definition for ‘labs’ +preview_theme: no visible global function definition for ‘textGrob’ +preview_theme: no visible global function definition for ‘gpar’ +random_swatch_colour: possible error in swatch(x): unused argument (x) +random_swatch_colour: no visible binding for global variable ‘x’ +rotate_axes_text: no visible global function definition for ‘theme’ +rotate_axes_text: no visible global function definition for + ‘element_text’ +rotate_x_text: no visible global function definition for ‘theme’ +rotate_x_text: no visible global function definition for ‘element_text’ +rotate_y_text: no visible global function definition for ‘theme’ +rotate_y_text: no visible global function definition for ‘element_text’ +set_theme: no visible global function definition for ‘theme’ +set_theme: no visible global function definition for ‘element_line’ +set_theme: no visible global function definition for ‘element_rect’ +set_theme: no visible global function definition for ‘element_text’ +set_theme: no visible global function definition for ‘rel’ +set_theme: no visible global function definition for ‘element_blank’ +theme_scales : updateGeoms: no visible global function definition for + ‘update_geom_defaults’ +theme_scales: no visible global function definition for + ‘update_geom_defaults’ +theme_scales : : no visible global function definition for + ‘discrete_scale’ +theme_scales : : no visible global function definition for + ‘continuous_scale’ + +Found the following assignments to the global environment: +File ‘ggthemr/R/theme_scales.R’: + assign("scale_colour_discrete", function(...) discrete_scale("colour", + "ggthemr", discrete_colours(colours), ...), envir = .GlobalEnv) + assign("scale_fill_discrete", function(...) discrete_scale("fill", + "ggthemr", discrete_colours(colours), ...), envir = .GlobalEnv) + assign("scale_colour_continuous", function(...) continuous_scale("colour", + "ggthemr", scales::seq_gradient_pal(palette$gradient[["low"]], + palette$gradient[["high"]]), ...), envir = .GlobalEnv) + assign("scale_fill_continuous", function(...) continuous_scale("fill", + "ggthemr", scales::seq_gradient_pal(palette$gradient[["low"]], + palette$gradient[["high"]]), ...), envir = .GlobalEnv) + assign("scale_colour_gradient", function(...) continuous_scale("colour", + "ggthemr", scales::seq_gradient_pal(palette$gradient[["low"]], + palette$gradient[["high"]]), ...), envir = .GlobalEnv) + assign("scale_fill_gradient", function(...) continuous_scale("fill", + "ggthemr", scales::seq_gradient_pal(palette$gradient[["low"]], + palette$gradient[["high"]]), ...), envir = .GlobalEnv) +* checking Rd files ... OK +* checking Rd metadata ... OK +* checking Rd line widths ... OK +* checking Rd cross-references ... OK +* checking for missing documentation entries ... WARNING +Undocumented code objects: + ‘ggthemr_active’ ‘no_major_gridlines’ ‘no_major_x_gridlines’ + ‘no_major_y_gridlines’ ‘no_minor_gridlines’ ‘no_minor_x_gridlines’ + ‘no_minor_y_gridlines’ +All user-level objects in a package should have documentation entries. +See the chapter ‘Writing R documentation files’ in the ‘Writing R +Extensions’ manual. +* checking for code/documentation mismatches ... WARNING +Functions or methods with usage in documentation object 'plot.ggthemr.swatch' but not in code: + plot.ggthemr.swatch + +* checking Rd \usage sections ... WARNING +Undocumented arguments in documentation object 'colour_plot' + ‘...’ + +Undocumented arguments in documentation object 'darken_palette' + ‘amount’ + +Undocumented arguments in documentation object 'ggthemr' + ‘line_weight’ + +Objects in \usage without \alias in documentation object 'plot.ggthemr': + ‘plot.ggthemr_palette’ + +Undocumented arguments in documentation object 'rotate_y_text' + ‘angle’ + +Undocumented arguments in documentation object 'set_swatch' + ‘swatch_colours’ +Documented arguments not in \usage in documentation object 'set_swatch': + ‘themr’ ‘new_swatch’ + +Undocumented arguments in documentation object 'set_themr' + ‘value’ + +Documented arguments not in \usage in documentation object 'swatch': + ‘x’ + +Functions with \usage entries need to have the appropriate \alias +entries, and all their arguments documented. +The \usage entries must correspond to syntactically valid R code. +See the chapter ‘Writing R documentation files’ in the ‘Writing R +Extensions’ manual. +* checking Rd contents ... OK +* checking for unstated dependencies in examples ... OK +* checking examples ... ERROR +Running examples in ‘ggthemr-Ex.R’ failed +The error most likely occurred in: + +> base::assign(".ptime", proc.time(), pos = "CheckExEnv") +> ### Name: colour_plot +> ### Title: Plot colours +> ### Aliases: colour_plot colour_plot.character colour_plot.ggthemr +> ### colour_plot.ggthemr_palette colour_plot.ggthemr_swatch +> +> ### ** Examples +> +> colour_plot(c('#de6757', 'pink')) +> colour_plot(ggthemr('sea')) +Error in swatch(x) : unused argument (x) +Calls: colour_plot -> colour_plot.ggthemr -> plot_colours -> swatch +Execution halted +Error: Command failed (1) +In addition: Warning messages: +1: @S3method is deprecated. Please use @export instead +2: @S3method is deprecated. Please use @export instead +3: @S3method is deprecated. Please use @export instead +4: @S3method is deprecated. Please use @export instead +5: @S3method is deprecated. Please use @export instead +6: @S3method is deprecated. Please use @export instead +7: @S3method is deprecated. Please use @export instead +8: @S3method is deprecated. Please use @export instead \ No newline at end of file diff --git a/misc/prepare.sh b/misc/prepare.sh new file mode 100644 index 0000000..1d87055 --- /dev/null +++ b/misc/prepare.sh @@ -0,0 +1 @@ +cp -r NAMESPACE DESCRIPTION R man misc/pre-build \ No newline at end of file diff --git a/misc/preview_theme.R b/misc/preview_theme.R new file mode 100644 index 0000000..69019b1 --- /dev/null +++ b/misc/preview_theme.R @@ -0,0 +1,67 @@ +#' @importFrom gridExtra grid.arrange +#' @importFrom grid textGrob gpar +preview_theme <- function(themr = NULL, save_to = NULL) { + + if (!exists(".Random.seed", mode="numeric")) + sample(NA) + + old_seed <- .Random.seed + + data('diamonds', package = 'ggplot2', envir = environment()) + + set.seed(1) + data_subset <- seq(0, 100, 5) + usage <- as.numeric(WWWusage)[data_subset] + times <- (1:100)[data_subset] + www <- data.frame(Users = usage, Minute = times, Measure = 'Actual') + www <- rbind(www, transform(www, Users = jitter(www$Users, factor = 500) / 2, Measure = 'Jitter')) + + drivers <- transform(as.data.frame(Seatbelts), Year = factor(1969:1984)) + names(drivers)[1] <- 'Deaths' + + car_data <- data.frame( + MPG = mtcars$mpg, + Cylinders = factor(mtcars$cyl) + ) + + diamond_data <- data.frame( + Cut = factor(diamonds$cut), + Price = diamonds$price + ) + + driver_x <- scale_x_discrete(breaks = seq(1969, 1984, 3), label = function(x) paste0("'", substr(x, 3, 4))) + display_theme <- list(theme(legend.position = 'none'), scale_y_continuous(label = function(x) format(x, big.mark = ",", scientific = FALSE))) + + display <- list( + + ggplot(www, aes_string(x = 'Minute', y = 'Users', colour = 'Measure', shape = 'Measure')) + + geom_line() + + geom_point(size = 3L, colour = get_themr()$palette$background) + + geom_point(size = 1.8) + + scale_shape_manual(values = c(15L, 16L)) + + legend_top(), + + ggplot(car_data, aes_string(x = 'MPG', fill = 'Cylinders', colour = 'Cylinders')) + + geom_density(alpha = 0.75) + + ylab('Density') + + legend_top(), + + ggplot(diamond_data, aes_string(x = 'Price', fill = 'Cut')) + + geom_histogram(binwidth = 850) + + display_theme + + xlab('Price (USD)') + + ylab('Count') + + scale_x_continuous(label = function(x) paste0(x / 1000, 'k')), + + ggplot(drivers, aes_string(x = 'Year', y = 'Deaths')) + + geom_boxplot(size = 0.25) + + ylab('Monthly Deaths') + + display_theme + + driver_x + + ) + + assign(".Random.seed", old_seed, envir=globalenv()) + do.call(grid.arrange, display) + +} diff --git a/R/preview_layout.R b/scripts/preview_layout.R similarity index 100% rename from R/preview_layout.R rename to scripts/preview_layout.R diff --git a/R/preview_theme.R b/scripts/preview_theme.R similarity index 95% rename from R/preview_theme.R rename to scripts/preview_theme.R index 6baacc7..05aa1ff 100644 --- a/R/preview_theme.R +++ b/scripts/preview_theme.R @@ -24,7 +24,7 @@ preview_theme <- function(themr = NULL, save_to = NULL) { ggplot(www, aes_string(x = 'Minute', y = 'Users', colour = 'Measure', shape = 'Measure')) + geom_line() + - geom_point(size = 3L, colour = get_themr()$palette$background) + + geom_point(size = 3L, colour = ggthemr:::get_themr()$palette$background) + geom_point(size = 1.8) + scale_shape_manual(values = c(15L, 16L)) + legend_top(),