ShadeR

ShadeR provide a new geom for ggplot2, geom_fleck, to make dot density plots and an associated stat, aspect_shading, to generate shadding effect.

Installation

ShadeR is inspired by this post of Elio Campitelli and relies on his package metR for the computation of derivatives.

These two packages can be installed with the following comamands:

# install.packages("devtools")
devtools::install_github("eliocamp/metR")

# And intsallation of ShadeR:
devtools::install_github("Clement-Viguier/ShadeR")

Examples

An example of The Andes relief and Pacific Ocean ploted with geom_fleck and stat_aspect_shading: The Andes Like any geom_similar to point, geom_fleck accepts changes of aes like colour, used here to distinguish the ocean from the land.

THe resolution can be given as an aesthetic or is computed if res = NULL in the geom_fleck call.

Another aesthetic is * sun.angle * that modify the position of the sun for the shading computation by stat functions (only stat_aspect_shading for now). Below it is used with image_animate: Volcano rotating shade

library(ggplot2)
library(ShadeR)

Three one-line examples you can try once ShadeR is installed:

ggplot(volcano2, aes(x, y, z = z)) + geom_fleck()+ coord_fixed() + theme_void() + ggtitle("Volcano shaded with geom_fleck")

ggplot(volcano2, aes(x, y, z = z)) + geom_fleck(stat = "identity", density = 10)+ coord_fixed() + theme_void() + ggtitle("Volcano altitude visualised with geom_fleck and stat = \"identity\"." )

ggplot(volcano2, aes(x, y, z = z)) + geom_fleck(aes(colour = (x+y)^2))+ coord_fixed() + theme_void() + ggtitle("Color and density are also controlled with aes()." )


# Alternative stat functions provide alternate shading function from the rayshader package
 ggplot(volcano2, aes(x, y, z = z)) + geom_fleck(stat = "ray_shading")+ coord_fixed() + theme_void()
 ggplot(volcano2, aes(x, y, z = z)) + geom_fleck(stat = "sphere_shading")+ coord_fixed() + theme_void()

Author

Acknowledgments



Clement-Viguier/ShadeR documentation built on Nov. 6, 2019, 4:46 p.m.