-
Notifications
You must be signed in to change notification settings - Fork 4
/
README.Rmd
120 lines (92 loc) · 3.96 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
---
output: github_document
editor_options:
chunk_output_type: console
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
cache = FALSE,
fig.align = 'center'
)
set.seed(1)
```
## Prettified Base Graphics
[![R-CMD-check](https://github.com/jumpingrivers/prettyB/workflows/R-CMD-check/badge.svg)](https://github.com/jumpingrivers/prettyB/actions)
[![CRAN](http://www.r-pkg.org/badges/version/prettyB)](https://cran.r-project.org/package=prettyB)
[![Lifecycle: maturing](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://lifecycle.r-lib.org/articles/stages.html)
[![Coverage status](https://codecov.io/gh/jumpingrivers/prettyB/branch/master/graph/badge.svg)](https://codecov.io/github/jumpingrivers/prettyB?branch=master)
[![Downloads](http://cranlogs.r-pkg.org/badges/prettyB?color=brightgreen)](https://cran.r-project.org/package=prettyB)
Anyone who uses R Base graphics, have a 100 and 1 tweaks that they use to make the
figures more presentable. This package aims to capture the tweaks in one place.
## Installation
The package is still being developed and the graphs are subject to change.
The package is on CRAN and can be installed in the usual way
```{r eval = FALSE}
install.packages("prettyB")
```
To install the dev version, try
```{r, eval=FALSE}
devtools::install_github("jumpingrivers/prettyB")
```
The package can then be loaded in the usual way
```{r, message=FALSE}
library("prettyB")
```
## Usage
All plotting functions work exactly as before, with the same inputs. The difference
is that the defaults have been changed. For example, compare
```{r, plot-minimal,fig.width=12}
op = par(mfrow = c(1, 2))
plot(iris$Sepal.Length, iris$Sepal.Width)
plot_p(iris$Sepal.Length, iris$Sepal.Width)
```
When you first call a __prettyB__, it changes the underlying `par()` and
`palette()`. You can reset this via
```{r}
prettyB::reset_prettyB()
```
The core idea of __prettyB__ is that no new arguments are introducted to the
plot functions. This means, that no changes to existing code
are required
```{r, plot-minimal-full,fig.width=6, echo = -1}
op = par(mfrow = c(1, 1))
plot_p(iris$Sepal.Length, iris$Sepal.Width,
xlab = "Length", ylab = "Width",
main = "The Iris data set",
sub = "I hate this data too")
```
## Other plots
The package also prettifies other functions
* Histograms
```{r, echo=c(-1, -2)}
prettyB::reset_prettyB()
par(mfrow = c(1, 2))
z = rt(100, 4)
hist(z, main = "The t-distribution")
hist_p(z, main = "The t-distribution")
```
* barplots
```{r, echo=-1}
par(mfrow = c(1, 2), cex = 0.9)
barplot(VADeaths, main = "Death Rates in Virginia")
barplot_p(VADeaths, main = "Death Rates in Virginia")
```
## Package Rationale
This package is __not__ a replacement for __ggplot2__ or other R related plotting packages. Instead, it has a few simple aims
* provide package authors a low dependency method of making their plots look pretty
* provide academics with a way of generating nice plots, but not worry about future changes in R
* provide a simple way for improving the look and feel of plots in teaching
Since the generated plots by __prettyB__ use standard base graphics, with no new arguments, this makes plots future proof. As a fall-back, just remove the `_p`.
I picked up the general style a few years ago, but the book
[Fundamentals of Data Visualization](https://www.amazon.com/Fundamentals-Data-Visualization-Informative-Compelling/dp/1492031089/) has made it a bit
more consist. The author also provided a free
[online](https://serialmentor.com/dataviz/) version.
## Other information
* If you have any suggestions or find bugs, please use the github [issue tracker](https://github.com/jumpingrivers/prettyB/issues)
* Feel free to submit pull requests
---
Development of this package was supported by [Jumping Rivers](https://www.jumpingrivers.com)