Skip to content

Set up continuous integration #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@
^appveyor\.yml$
^scripts/*
^misc/*
^ggthemr\.Rproj$
^tic\.R$
58 changes: 58 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# R for travis: see documentation at https://docs.travis-ci.com/user/languages/r
# Default configuration for use with tic package
# tic documentation to get started: https://ropenscilabs.github.io/tic/
# Usually you shouldn't need to change the first part of the file

# DO NOT CHANGE THE CODE BELOW
before_install:
- R -q -e 'if (!requireNamespace("remotes")) install.packages("remotes")'
- R -q -e 'if (getRversion() < "3.2" && !requireNamespace("curl")) install.packages("curl")'
- R -q -e 'remotes::install_github("ropenscilabs/tic", upgrade = "always"); print(tic::dsl_load()); tic::prepare_all_stages()'
- R -q -e 'tic::before_install()'
install: R -q -e 'tic::install()'
after_install: R -q -e 'tic::after_install()'
before_script: R -q -e 'tic::before_script()'
script: R -q -e 'tic::script()'
after_success: R -q -e 'tic::after_success()'
after_failure: R -q -e 'tic::after_failure()'
before_deploy: R -q -e 'tic::before_deploy()'
deploy:
provider: script
script: R -q -e 'tic::deploy()'
on:
all_branches: true
after_deploy: R -q -e 'tic::after_deploy()'
after_script: R -q -e 'tic::after_script()'
# DO NOT CHANGE THE CODE ABOVE

# Custom parts:

# Header
language: r
sudo: false
dist: xenial
cache: packages
latex: false

#env
env:
global:
- MAKEFLAGS="-j 2"

#jobs
jobs:
include:
- stage: test
r: devel
env:
- INSTALL_DEV_VERSIONS=true
- r: release
env:
- BUILD_PKGDOWN=true

#matrix: Early abortion of failed builds
matrix:
fast_finish: true

#services
services:
5 changes: 5 additions & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ source('scripts/preview_layout.R')
ggthemr
========================================================

<!-- badges: start -->
[![Travis build status](https://travis-ci.org/krlmlr/ggthemr.svg?branch=master)](https://travis-ci.org/krlmlr/ggthemr)
[![CRAN status](https://www.r-pkg.org/badges/version/ggthemr)](https://cran.r-project.org/package=ggthemr)
<!-- badges: end -->

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.
Expand Down
103 changes: 78 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,32 @@
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:
<!-- badges: start -->
[![Travis build
status](https://travis-ci.org/krlmlr/ggthemr.svg?branch=master)](https://travis-ci.org/krlmlr/ggthemr)
[![CRAN
status](https://www.r-pkg.org/badges/version/ggthemr)](https://cran.r-project.org/package=ggthemr)
<!-- badges: end -->

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.
- 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.
There are a number of preset palettes and layouts, and methods to create
your own colour schemes.

Installation
------------

This package is still under development, but can be installed using [devtools](http://cran.r-project.org/web/packages/devtools/index.html).
This package is still under development, but can be installed using
[devtools](http://cran.r-project.org/web/packages/devtools/index.html).

``` r
devtools::install_github('cttobin/ggthemr')
Expand All @@ -42,7 +55,8 @@ 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:
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()
Expand All @@ -51,9 +65,16 @@ ggthemr_reset()
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

Expand Down Expand Up @@ -130,7 +151,9 @@ There are a wide variety of themes in this package (and more on the way). Some o
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
# Random colours that aren't white.
Expand All @@ -149,12 +172,16 @@ example_plot + ggtitle(':(')

![](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.
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

Expand All @@ -179,7 +206,10 @@ The layout of a theme controls the appearance and position of the axes, gridline
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 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.

![](README_files/figure-markdown_github/unnamed-chunk-28-1.png)

Expand All @@ -190,7 +220,9 @@ Plot margins and space between axes titles and lines etc. is controlled with the
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
ggthemr('earth', type = 'inner')
Expand All @@ -209,7 +241,8 @@ 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:
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')
Expand All @@ -218,7 +251,8 @@ example_plot

![](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:
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)
Expand All @@ -227,18 +261,25 @@ example_plot

![](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:
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_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.
Ill 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.
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')
Expand All @@ -250,7 +291,12 @@ mpg_plot

![](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
swatch()
Expand All @@ -270,18 +316,25 @@ mpg_plot + scale_fill_manual(values = rev(to_swap))

![](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.
**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.

A note about theme setting
--------------------------

ggthemr does three different things while setting a theme.

1. It updates the default ggplot2 theme with the specified ggthemr theme by using the `ggplot2::theme_set()` function.
2. It modifies the aesthetic defaults for all geoms using the `ggplot2::update_geom_defaults()` function.
3. It creates functions for all the different scales in the global environment.
1. It updates the default ggplot2 theme with the specified ggthemr
theme by using the `ggplot2::theme_set()` function.
2. It modifies the aesthetic defaults for all geoms using the
`ggplot2::update_geom_defaults()` function.
3. It creates functions for all the different scales in the global
environment.

In case, if you do not want to set the theme this way, use the `set_theme = FALSE` option while using the `ggthemr` function. An example of setting theme, geom aesthetic defaults and scales manually:
In case, if you do not want to set the theme this way, use the
`set_theme = FALSE` option while using the `ggthemr` function. An
example of setting theme, geom aesthetic defaults and scales manually:

``` r
ggthemr_reset()
Expand Down
Binary file modified README_files/figure-markdown_github/unnamed-chunk-10-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-11-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-12-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-13-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-14-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-15-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-16-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-17-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-18-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-19-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-20-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-21-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-22-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-23-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-24-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-25-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-26-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-27-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-28-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-29-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-30-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-31-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-32-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-33-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-34-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-35-1.png
Binary file modified README_files/figure-markdown_github/unnamed-chunk-37-1.png
Binary file modified README_files/figure-markdown_github/unnamed-chunk-38-1.png
Binary file modified README_files/figure-markdown_github/unnamed-chunk-38-2.png
Binary file modified README_files/figure-markdown_github/unnamed-chunk-38-3.png
Binary file modified README_files/figure-markdown_github/unnamed-chunk-38-4.png
Binary file modified README_files/figure-markdown_github/unnamed-chunk-5-1.png
Binary file modified README_files/figure-markdown_github/unnamed-chunk-6-1.png
Binary file modified README_files/figure-markdown_github/unnamed-chunk-7-1.png
Binary file modified README_files/figure-markdown_github/unnamed-chunk-8-1.png
Binary file modified README_files/figure-markdown_github/unnamed-chunk-9-1.png
66 changes: 66 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# DO NOT CHANGE the "init" and "install" sections below

# Download script file from GitHub
init:
ps: |
$ErrorActionPreference = "Stop"
Invoke-WebRequest http://raw.github.com/krlmlr/r-appveyor/master/scripts/appveyor-tool.ps1 -OutFile "..\appveyor-tool.ps1"
Import-Module '..\appveyor-tool.ps1'

install:
- ps: Bootstrap
- cmd: Rscript -e "writeLines('options(repos = \'https://cloud.r-project.org\')', '~/.Rprofile')"
- cmd: Rscript -e "getOption('repos')"
- cmd: Rscript -e "if (!requireNamespace('remotes')) install.packages('remotes')"
- cmd: Rscript -e "if (getRversion() < '3.2' && !requireNamespace('curl')) install.packages('curl')"
- cmd: Rscript -e "remotes::install_cran('tic', type = 'binary', upgrade = 'always'); print(tic::dsl_load()); tic::prepare_all_stages()"

cache:
- C:\RLibrary

before_build: Rscript -e "tic::before_install()"
build_script: Rscript -e "tic::install()"
after_build: Rscript -e "tic::after_install()"
before_test: Rscript -e "tic::before_script()"
test_script: Rscript -e "tic::script()"
on_success: Rscript -e "try(tic::after_success(), silent = TRUE)"
on_failure: Rscript -e "tic::after_failure()"
before_deploy: Rscript -e "tic::before_deploy()"
deploy_script: Rscript -e "tic::deploy()"
after_deploy: Rscript -e "tic::after_deploy()"
on_finish: Rscript -e "tic::after_script()"

# Adapt as necessary starting from here

#on_failure:
# - 7z a failure.zip *.Rcheck\*
# - appveyor PushArtifact failure.zip

environment:
# R_QPDF=true makes sure that R CMD check doesn't complain
# about a missing qpdf executable
R_QPDF: "true"
# The example below will not work for your repository,
# you need to encrypt your own token.
# Please follow https://ci.appveyor.com/tools/encrypt .
#GITHUB_PAT:
# secure: VXO22OHLkl4YhVIomSMwCZyOTx03Xf2WICaVng9xH7gISlAg8a+qrt1DtFtk8sK5

artifacts:
- path: '*.Rcheck\**\*.log'
name: Logs

- path: '*.Rcheck\**\*.out'
name: Logs

- path: '*.Rcheck\**\*.fail'
name: Logs

- path: '*.Rcheck\**\*.Rout'
name: Logs

- path: '\*_*.tar.gz'
name: Bits

- path: '\*_*.zip'
name: Bits
13 changes: 13 additions & 0 deletions tic.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
if (ci_has_env("INSTALL_DEV_VERSIONS")) {
get_stage("install") %>%
add_step(step_install_github(c("r-lib/scales", "tidyverse/ggplot2")))
}

do_package_checks()

if (ci_on_travis() && ci_has_env("BUILD_PKGDOWN")) {
get_stage("install") %>%
add_step(step_install_cran("gridExtra"))

do_pkgdown()
}