Skip to content

AndreaCirilloAC/paletter

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
R
 
 
 
 
man
 
 
 
 
 
 
 
 
 
 
 
 

paletteR

PaletteR is an R package that is able to draw an optimised palette from a custom image. The palette is obtained by applying statistical learning to the image provided and optimising the distribution of colours.

More on the math behind the package can be found at:

http://www.andreacirillo.com/2018/05/08/how-to-use-paletter-to-automagically-build-palettes-from-pictures/

Rdoc

example

Tondo Doni, Michelangelo Buonarroti, 1503-1504

Installation

The package is currently only on Github. You can install it as follows:

devtools::install_github("AndreaCirilloAC/paletter")

usage

image_path <- "path_to_your_image"
colours_vector <- create_palette(image_path = image_path,
number_of_colors =32,
type_of_variable =categorical")

ggplot(data = mtcars, aes(x = rownames(mtcars),y = hp,color = rownames(mtcars),
                          fill = rownames(mtcars))) +
  geom_bar(stat = 'identity') +
  scale_color_manual(values = colours_vector) +
  scale_fill_manual(values=colours_vector)+
  theme_minimal() +
  guides(size = FALSE) +
  theme(legend.position = "bottom") +
  labs(title = "disp vs hp")+
  coord_flip()