[R PACKAGE] A ggplot2 extension for 3D visualization
ggcube is an R package I developed to extend ggplot2’s native capabilities into the third dimension. 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.
The package provides a framework where users can define 3D projections and then use familiar ggplot2 syntax alongside specialized projection functions to create sophisticated 3D visualizations. Rather than introducing a completely new paradigm, ggcube builds upon the existing ggplot2 foundation, allowing users to leverage their existing knowledge while adding the power of the z-axis.
This project emerged from my own need for high-quality, customizable 3D visualizations that maintain the aesthetic consistency and programmatic flexibility of the tidyverse ecosystem. While still under active development, the package already supports a range of projection types, visualization approaches, and customization options.
proj_data()
for projecting points, lines, and other geomsproj_surface()
for rendering 3D surfacesproj_ridgeline()
for creating Joy Division-style ridgeline plotsproj_margin()
for adding marginal plots on cube facesproj_panel()
and proj_gridlines()
for cube structure and reference linesproj_label()
for axis labelingThe package is useful for:
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.