Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ropensci-archive/styles

:no_entry: ARCHIVED :no_entry: Styles For Base Plots
https://github.com/ropensci-archive/styles

ozunconf17 r r-package rstats unconf

Last synced: 3 months ago
JSON representation

:no_entry: ARCHIVED :no_entry: Styles For Base Plots

Awesome Lists containing this project

README

        

styles
======

The goal of styles is to create and apply themes to base plots.

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

You can install styles from github with:

``` r
# install.packages("devtools")
devtools::install_github("ropenscilabs/styles")
```

Examples
--------

Let's compare default plot arguments to a styles:

``` r
library(styles)
library(default)

plot_mat <- matrix(1:8, nrow = 2, byrow = FALSE)
layout(plot_mat)

# plot with plot defaults; without setting a style
example_plots()

# plot with a style
style(better)
example_plots()
```

You can preview internal styles:

``` r
plot_style(better)
```

You can create your own styles:

``` r
blue_stars <- new_style(par = list(pch = 8),
graphics = list(plot.xy = list(col = "navyblue")))
style(blue_stars)
plot(mpg ~ wt, data = mtcars)
```

Once we have a style we like, we can apply it to all of our plots:

``` r
blue_dot_grey <- new_style(par = list(pch = 20,
cex=1.2,
bty="l",
col.axis = grey(0.4),
col.lab = grey(0.4),
fg = grey(0.4),
mar=c(4,4,1,1)),
graphics = list(plot.xy = list(col = "navyblue")))

style(blue_dot_grey)

plot_mat <- matrix(1:4, nrow = 2, byrow = FALSE)
layout(plot_mat)
plot(mpg ~ wt, data = mtcars)
plot(mpg ~ disp, data = mtcars)
plot(mpg ~ hp, data = mtcars)
plot(mpg ~ drat, data = mtcars)
```