Home

Awesome

<!-- README.md is generated from README.Rmd. Please edit that file -->

ggthreed - 3d geoms and stats for ggplot2<img src="man/figures/logo-with-pause.gif" align="right"/>

Travis build
status AppVeyor build
status

ggthreed is a collection of ggplot2 geoms which use the threed library.

What’s in the box:

Installation

You can install from github

# install.packages("devtools")
devtools::install_github("coolbutuseless/threed")
devtools::install_github("coolbutuseless/ggthreed")

Red/blue anaglyphs with stat_anaglyph()

Grab your glasses and lower your expectations!!

Usage

Example red/blue anaglyphs with points.

ggplot(mtcars) +
  geom_point(aes(mpg, y = wt, z = disp), stat = 'anaglyph', alpha = 0.5, zscale = 10) +
  theme_bw()
<img src="man/figures/README-unnamed-chunk-2-1.png" width="100%" />

Example of combined 3d projection and anaglyph

library(threed)

camera_to_world <- look_at_matrix(eye = c(1.5, 1.75, 3), at = c(0, 0, 0))

obj <- threed::mesh3dobj$cube %>%
  transform_by(invert_matrix(camera_to_world)) %>%
  translate_by(c(0, 0, -3)) %>%
  perspective_projection()

ggplot(obj, aes(x, y, z = z, group = element_id)) +
  geom_polygon(fill = NA, colour='black', aes(size = hidden), stat = 'anaglyph',
               zscale = 0.05, zoffset = -1.4, zinvert = FALSE) +
  scale_linetype_manual(values = c('TRUE' = "FF", 'FALSE' = 'solid')) +
  scale_size_manual(values = c('TRUE' = 0.1, 'FALSE' = 0.5)) +
  theme_void() +
  theme(legend.position = 'none') +
  coord_equal()
<img src="man/figures/README-gallery-cube-1.png" width="100%" />

Animated Anaglyph

Animated Icosahedron

See vignette('animated-anaglyph', package='ggthreed')

3d pie charts with geom_threedpie()

Usage

Issues/Limitations

Example - Simple Pie Chart

ggplot(mtcars) + 
  geom_threedpie(aes(x = as.factor(cyl))) + 
  theme_void() + 
  theme(legend.position = 'bottom')
<img src="man/figures/README-example-simple-1.png" width="500" />

Example - Facetted Pie Chart

ggplot(diamonds)  +
  geom_threedpie(aes(as.factor(cut))) +
  facet_wrap(~clarity, labeller = label_both) +
  labs(title = "Distribution of Diamond Cuts by Clarity") +
  scale_fill_brewer(name = "Cut", palette = 'Set2') +
  theme_void()
<img src="man/figures/README-example-facet-1.png" width="100%" />

Example - Behind the Scenes

<!-- end list -->
ggplot(mtcars) + 
  geom_threedpie(aes(x = as.factor(cyl)), alpha = 0.5) + 
  theme_void() + 
  theme(legend.position = 'bottom')
<img src="man/figures/README-example-behind-1.png" width="100%" />

Example - Pie configuration

User adjustable: