ggcube

[R PACKAGE] A ggplot2 extension for 3D visualization

ggcube example

Overview

ggcube is an R package I developed that lets you build 3D figures using ggplot2. While there are numerous 3D visualization libraries in R, none of them seamlessly integrate with the elegant grammar of graphics approach that makes ggplot2 so powerful and intuitive. ggcube aims to fill this gap.

The package is based around coord_3d() a coordinate function that lets you define rotation and projection parameters for plots that include x, y, and z aesthetic variables. ggcube also provides a variety of 3D-specific geoms to render surfaces, prisms, points, and paths in 3D; it also works with some standard ggplot2 layer functions. You can control plot geometry with 3D projection parameters, can apply a range of 3D lighting models, and can mix 3D layers with 2D layers rendered on cube faces. Standard ggplot2 features like faceting, themes, scales, and legends work as expected.

ggcube example

Key Features

Applications

Resources

The package is currently under active development and hasn’t been released to CRAN yet. You can install the development version from GitHub using devtools::install_github("matthewkling/ggcube"). The GitHub repository contains additional examples and documentation.

The images on this page are examples of ggcube in action; see the GitHub page for the associated code.

ggcube example