https://github.com/doehm/evoPalette
Evolve new colour palettes
https://github.com/doehm/evoPalette
Last synced: 13 days ago
JSON representation
Evolve new colour palettes
- Host: GitHub
- URL: https://github.com/doehm/evoPalette
- Owner: doehm
- Created: 2020-03-11T21:12:13.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-02-21T06:39:49.000Z (about 4 years ago)
- Last Synced: 2024-11-02T16:08:25.092Z (5 months ago)
- Language: R
- Homepage:
- Size: 3.85 MB
- Stars: 15
- Watchers: 4
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.Rmd
Awesome Lists containing this project
- jimsghstars - doehm/evoPalette - Evolve new colour palettes (R)
README
---
output: github_document
---```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-",
error = TRUE,
eval = FALSE,
fig.height = 5
)library(png)
library(grid)
library(shiny)
library(glue)
library(evoPalette)
```# evoPalette
evoPalette allows for the discovery and generation of new colour palettes for R. Taking user input it uses a genetic algorithm to spawn new palettes. This can be repeated as many times as needed to generate the desired palette.
## Installation
```{r}
devtools::install_github("doehm/evoPalette")
```## Getting started
To jump straight into it launch the Shiny app with
```{r}
launch_evo_palette()
```To generate the first set of palettes, click 'evolve'.
Select one or more palettes that you like and think may work well together from the check box and click 'evolve'.
The next generation of palettes will be created. Continue until you are happy with a palette.With each generation you'll notice how the palette is converging to a similar theme based on your selections, along with some variation of each individual colour and a chance of a completely random mutation.
Selecting only a single parent is convenient to generate minor variations on a single palette to tweak the colours. Random names are given to each new palette.
Select 'Example: Fill aesthetic' to see how the palette works in practice.
To save a palette, select the desired palette from the check box and click 'save'. A box will appear giving the opportunity to change the palette name. The palette is now accessible from
palette_box()
once the app is closed. You can save multiple palettes which will be collected in the palette box. The palette box will be refreshed when starting a new session so remember to save it to disk.
```{r, echo = FALSE, eval = TRUE}
load(normalizePath('./man/images/palette-box.Rdata'))
``````{r, eval = TRUE}
palette_box()
```To begin again, deselect all palettes and click 'evolve'. A new set of randomly selected palettes will be shown.
## Control
Select the parameters from the drop down in the menu.
* Number of colours to generate for each palette
* Number of palettes to generate at each evolution
* Mutation rate - Each colour in the palette has a probability of random mutation equal to this value (default p = 0.05)
* Mutation variation - Each colour will vary slightly around it's original value.
* Load existing palettes from the global environment. Object should be list, ideally with names i.e. the same format aspalette_box()
.
* Are you feeling lucky? Select for generating palettes from completely random colours.When you are happy with your selections, click 'evolve'
## Scales
The generated colour palettes can easily be added to ggplots using the scale functions \code{scale_fill_evo} and \code{scale_colour_evo}.
```{r}
library(ggplot2)
mpg %>%
ggplot(aes(x = displ, fill = class)) +
geom_histogram() +
scale_fill_evo("instructive_customers")
```
If no name is given the first palette in the list will be used.