Skip to content

Commit

Permalink
More doc, more examples
Browse files Browse the repository at this point in the history
  • Loading branch information
vikjam committed May 2, 2016
1 parent 903fa97 commit f3fa663
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 3 deletions.
2 changes: 1 addition & 1 deletion R/RColorLisa.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Color Palettes from the Masters
#'
#' This function allows you to easily load color palettes from great painters into R.
#' @param n Number of colors to return.
#' @param n Number of colors to return. Defaults to 5.
#' @param name Name of painting
#' @keywords colors
#' @export
Expand Down
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,41 @@
# RColorLisa
Easily load color palettes from great painters into R. Based on the wonderful work of Ryan McGuire who created the beautiful site [Color Lisa](http://colorlisa.com).

## Installation
```R
devtools::install_github("vikjam/RColorLisa")
```

## Usage

### Create a sequential palette for usage and show colors
### Examples
```R
# Create a sequential palette for usage and show colors
pretty.palette <- color.lisa.pal(5, "The Dream by Pablo Picasso")
image(1:5, 1, as.matrix(1:5), col = pretty.palette, xlab = "The Dream by Pablo Picasso",
ylab = "", xaxt = "n", yaxt = "n", bty = "n")
```
![the-dream](figures/the-dream.png)

```R
# ggplot2 example
library(ggplot2)
df <- data.frame(x = rep(c(2, 5, 7, 9, 12), 2),
y = rep(c(1, 2), each = 5),
z = factor(rep(1:5, each = 2))
)
escher.pal <- color.lisa.pal(5, "Gravity by M.C. Escher")
ggplot(df, aes(x, y)) + geom_tile(aes(fill = z)) +
scale_fill_manual(values = escher.pal)
```
![escher-tile](figures/escher-tile.png)

```R
# Slightly more practical ggplot2 example
library(ggplot2)
ernst.pal <- color.lisa.pal(5, "Woman, Old Man, and Flower by Max Ernst")
ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) +
geom_point(size = 3) +
scale_color_manual(values = ernst.pal)
```
![iris-ernst](figures/iris-ernst.png)
Binary file added figures/escher-tile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added figures/iris-ernst.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion grab-colors.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Hacky script to extract the colors
require 'nokogiri'
require 'pp'

color_lisa_html = File.open("color-lisa.html") { | f | Nokogiri::HTML(f) }

Expand Down

0 comments on commit f3fa663

Please sign in to comment.