This repository has been archived by the owner on May 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
README.Rmd
83 lines (61 loc) · 1.87 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
```
# styles
The goal of styles is to create and apply themes to base plots.
## Installation
You can install styles from github with:
```{r gh-installation, eval = FALSE}
# install.packages("devtools")
devtools::install_github("ropenscilabs/styles")
```
## Examples
Let's compare default plot arguments to a styles:
```{r example, fig.width=10, fig.align='center'}
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, fig.align='center'}
plot_style(better)
```
You can create your own styles:
```{r, fig.height = 5, fig.width = 5, fig.align='center'}
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, fig.align='center'}
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)
```