knitr::opts_chunk$set( collapse = TRUE, comment = "#>", message = FALSE, warning = FALSE, fig.width = 6 ) library(dplyr) library(ggplot2) library(ggRtsy) library(purrr) exampleData <- starwars %>% filter(mass < 1000) plotExample <- ggplot(exampleData, aes(x = height, y = mass)) + geom_point(size = 3) + scale_x_continuous()
The ggArtsyR()
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.
knitr::kable(head(goghColors,10))
ggRtsy also has a function that work alongside ggplot2()
to create more interesting data visualizations and add contextual information to the user’s plots. This main function is RectangleFiller()
, which divides data visualizations into a specified number of colored quadrants based on the number of input colors, improving the readability of graphs.
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.
RectangleFiller(plotExample, c("#e32636", "#9966cc", "#f4c2c2", "#e16827"))
This package comes with rgbToHex, converting rgb colors into hex code colors.
rgbToHex(c("(225, 104, 39)","(60, 90, 202)"))
The dataset goghPaintingSets contains a list of every Gogh painting, some information about them, and a set of colors randomly pulled from it. This can be used to make your own Gogh themed colorsets.
knitr::kable(head(goghPaintingSets,4))
For ease of use, gogh_palettes_pop is a list of color palettes from the most well known Gogh paintings.
cafeTerrace
= '#2A6BBF', '#3F6CA6', '#F2C84B', '#D99036', '#BF6734'
.jpg!Large.jpg){width=200px}
scale_color_gogh
ContinuousplotExample2 <- ggplot(exampleData, aes(x = height, y = mass, color = birth_year)) + geom_point(size = 2) + scale_color_gogh(palette = "cafeTerrace", discrete = FALSE) + theme_minimal() plotExample2
scale_color_gogh
Discreteggplot(storms, aes(x = hour, y = wind, color = status)) + geom_point(size = 3) + scale_color_gogh(palette = "wheatField", discrete = TRUE, reverse=FALSE) + theme_minimal()
scale_fill_gogh
Discreteggplot(storms, aes(x = category, fill = status)) + geom_bar() + scale_fill_gogh(palette = "almondBlossoms", discrete = TRUE, reverse=FALSE) + theme_minimal()
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.