-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathREADME.Rmd
150 lines (91 loc) · 5.06 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
```
# ggRtsy <img src="man/figures/logo.png" align="right" height="139" />
<!-- badges: start -->
[![R-CMD-check](https://github.com/katelyndiaz/ggRtsy/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/katelyndiaz/ggRtsy/actions/workflows/R-CMD-check.yaml)
[![R](https://github.com/katelyndiaz/ggRtsy/actions/workflows/r.yml/badge.svg)](https://github.com/katelyndiaz/ggRtsy/actions/workflows/r.yml)
[![CRAN RStudio mirror downloads](http://cranlogs.r-pkg.org/badges/ggRtsy)
[![CRAN status](https://www.r-pkg.org/badges/version/ggRtsy)](https://CRAN.R-project.org/package=ggRtsy)
<!-- badges: end -->
### Overview
The 'ggRtsy' package works with 'ggplot2' to add an additional color palette to the user’s repertoire. This is the `goghColors` dataset, which contains the RGB and hex codes of colors picked from Van Gogh paintings. It has been broken down into an easy-to-use color palette based on Van Gogh's most famous paintings, in the `gogh_palettes_pop` list.
#### Functions within the package:
It also has a function that work alongside ggplot to create more interesting data visualizations and add contextual information to the user’s plots.
- RectangleFiller() - divides data visualizations into a specified number of colored quadrants based on the number of input colors, improving the readability of graphs.
- scale_color_gogh() - used to color the point/lines of your ggplot
- scale_fill_gogh() - used to fill the inner color/bars of your ggplot
- rgbToHeX() - used to convert rgb color codes to hex color codes
- gogh_interpolate() - interpolates between the colors in `gogh_palettes_pop`
### Usage example
```{r, include=FALSE}
# Hidden chunk because it is setup for example
library(dplyr)
library(ggplot2)
library(ggRtsy)
library(purrr)
exampleData <- starwars %>%
filter(mass < 1000)
plotExample <- ggplot(exampleData, aes(x = height, y = mass)) +
geom_point() +
scale_x_continuous()
```
Using Hex Codes from the dataset `goghColors`, three colors were added on top of a ggplot() sample scatter plot. Based on the plot, the function automatically calculated three equal widths of the rectangles, and stretched them to upper and lower bounds on the y-axis.
```{r ex1, warning=FALSE}
RectangleFiller(plotExample, c("#e32636", "#9966cc", "#f4c2c2"))
```
#### Continuous scale_color_gogh() example using the `cafeTerrace` color palette:
```{r ex2, warning=FALSE, message=FALSE}
ggplot(exampleData, aes(x = height, y = mass, color = birth_year)) +
geom_point(size = 3) +
scale_color_gogh(palette = "cafeTerrace", discrete = FALSE, reverse = TRUE) +
theme_minimal()
```
#### Discrete scale_fill_gogh() example using the `almondBlossoms` color palette:
```{r ex3, warning=FALSE, message=FALSE}
ggplot(storms, aes(x = category, fill = status)) +
geom_bar() +
scale_fill_gogh(palette = "almondBlossoms", discrete = TRUE, reverse = FALSE) +
theme_minimal()
```
This package also comes with rgbToHex(), converting rgb colors into hex code colors.
```{r}
rgbToHex(c("(225, 104, 39)", "(60, 90, 202)"))
```
### Installation instructions
Get the development version from GitHub:
```{r, message=FALSE, eval=FALSE}
# Install remotes if needed:
# install.packages("remotes")
remotes::install_github("katelyndiaz/ggRtsy")
```
And load it with
```{r}
library(ggRtsy)
```
### Palettes
`starryNight` = '#23338C', '#30478C', '#5377A6', '#BDBF7E', '#BFA72C'
![](https://uploads4.wikiart.org/00142/images/vincent-van-gogh/the-starry-night.jpg!Large.jpg){width=400px}
`sunflowers` = '#74A629', '#F2EB80', '#F2E085', '#BF9821', '#A6681C'
![](https://uploads7.wikiart.org/images/vincent-van-gogh/still-life-vase-with-fifteen-sunflowers-1888-1.jpg!Large.jpg){width=400px}
`selfPortrait` = '#021F59', '#63A5BF', '#8C701C', '#BF9B6F', '#730202'
![](https://uploads8.wikiart.org/images/vincent-van-gogh/self-portrait-1889-1.jpg!Large.jpg){width=400px}
`wheatField` = '#73A9D9', '#477332', '#D9B13B', '#D98E32', '#A66329'
![](https://uploads4.wikiart.org/images/vincent-van-gogh/wheat-field-with-cypresses-at-the-haude-galline-near-eygalieres-1889-2.jpg!Large.jpg){width=400px}
`cafeTerrace` = '#2A6BBF', '#3F6CA6', '#F2C84B', '#D99036', '#BF6734'
![](https://uploads2.wikiart.org/images/vincent-van-gogh/cafe-terrace-place-du-forum-arles-1888(1).jpg!Large.jpg){width=400px}
`rhoneStarry` = '#073359', '#27668C', '#5A98BF', '#60734D', '#A3A658'
![](https://uploads0.wikiart.org/00175/images/vincent-van-gogh/starry-night-over-the-rhone.jpg!Large.jpg){width=400px}
`irises` = '#415AA6', '#6382BF', '#65A67C', '#8CA653', '#A66D58'
![](https://uploads0.wikiart.org/00213/images/vincent-van-gogh/antique-3840759.jpg!Large.jpg){width=400px}
`almondBlossoms` = '#236E8C', '#20788C', '#49B3BF', '#41BFBF', '#BDBF75'
![](https://uploads6.wikiart.org/images/vincent-van-gogh/branches-with-almond-blossom-1890(1).jpg!Large.jpg){width=400px}
### See also
* [tayloRswift package](https://github.com/asteves/tayloRswift)