Code Monkey home page Code Monkey logo

inrainbows's Introduction

inRainbows

An attempt at producing R colour palettes based on Radiohead album artwork. This project is a work in progress and may not work as expected!

Palette creation

The colour palettes are produced by first running kmeans on the RGB coordinates of the album covers with a specification that 20 groups are returned (the value of 20 groups was picked after some trial and error, as lower group numbers would sometimes result in key colours or accent colours in the album cover not being picked out).

After the palettes containing 20 colours each were produced, I manually reduced the number of colours in each palette in order to remove very visually similar (to my eye!) colours and very light (or white) colours, as they are rarely useful for visualisations (although this is something I may want to reconsider at some point). I am a bit conflicted about manually removing light colours as they are an essential part of the palette that represents the album artwork. But on the other hand, white (or very light colours) in a palette make it unuseable for most plotting situations. Although it also makes me wonder wether I should remove the very dark (black) colours.

Example palette creation

The two examples below show the original album cover, the album cover recreated from only the 20 colours picked from the kmeans clustering, the 20 colour palette and the final (manually) reduced palette.

The bends

“test”

King of limbs

“test”

Package useage

Add package to search path

library(inRainbows)

Visualise all palettes with inrainbows_summary()

inrainbows_summary()

Palette colours can be generated with inrainbows("album", n)

inrainbows("ok_computer", 3)
#> [1] "#E5EBF3" "#9DB5CC" "#6993CC"

Palettes can be used with ggplot by using scale_fill_inrainbows() and scale_colour_inrainbows()

library(ggplot2)

ggplot(morley, aes(Expt, Speed, fill = factor(Expt))) +
  geom_boxplot() +
  scale_fill_inrainbows("kid_a", guide=FALSE)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.