Uses the image color scale.

1 2 3 4 5 6 7 8 |

`...` |
parameters to |

`image` |
Matrix The image from which the palette will be extracted from. Should
be a 3 (or more) dimensional matrix. The output of a function such as |

`n` |
For continuous color scales, you may optionally pass in an integer, n. This allows some control over the scale, if n is too large the scale has too many colors and ceases to be meaningul. n = 3 to n = 5 is recommended. |

`choice` |
Function Defines how the color will be chosen from the final color cubes.
The default choice is to take the |

`volume` |
Logical volume controls the method for choosing which color cube to split
at each iteration of the algorithm. The default choice (when |

`discrete` |
generate a discrete palette? (default: |

For `discrete == TRUE`

(the default) the function will return a `discrete_scale`

with the plot-computed
number of colors. All other arguments are as to
scale_fill_gradientn or scale_color_gradientn.

See image_palette for more information on the color scale.

`median_cut`

`image_palette`

`vbox`

`display_image`

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ```
library(ggplot2)
# ripped from the pages of ggplot2
your_image <- jpeg::readJPEG(system.file("img", "Rlogo.jpg", package="jpeg"))
display_image(your_image)
#Discrete scale example
p <- ggplot(mtcars, aes(wt, mpg))
p + geom_point(size=4, aes(colour = factor(cyl))) +
scale_color_image(image = your_image) +
theme_bw()
#Continuous scale example
dsub <- subset(diamonds, x > 5 & x < 6 & y > 5 & y < 6)
dsub$diff <- with(dsub, sqrt(abs(x-y))* sign(x-y))
d <- ggplot(dsub, aes(x, y, colour=diff)) + geom_point()
d + scale_color_image(image = your_image, discrete=FALSE) + theme_bw()
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

All documentation is copyright its authors; we didn't write any of that.