glow

Build Status CRAN_Status_Badge

A package for making glow-y plots

The glow package is a framework for creating plots with glowing points as an alternative way of plotting large point clouds.

Installation

remotes::install_github("traversc/glow")

Some advantages over traditional techniques

Usage

Creating a glow plot is done through the GlowMapper or GlowMapper4 classes, which utilize the R6 class framework.

The class function $map creates a raster that can be plotted with ggplot’s geom_raster.

See the help files and tests/examples.r for more information and examples.

library(glow)
library(ggplot2)
library(viridisLite) # Magma color scale

# Load the dataset
data(diamonds)
gm <- GlowMapper$new(xdim=2000, ydim = 2000, blend_mode = "screen", nthreads=nt)
gm$map(x=diamonds$carat, y=diamonds$price, intensity=1, radius = .1)
pd <- gm$output_dataframe(saturation = 1)
ggplot() + 
  geom_raster(data = pd, aes(x = pd$x, y = pd$y, fill = pd$value), show.legend = F) +
  scale_fill_gradientn(colors = additive_alpha(magma(12))) +
  coord_fixed(gm$aspect(), xlim = gm$xlim(), ylim = gm$ylim()) + 
  labs(x = "carat", y = "price") + 
  theme_night(bgcolor = magma(1))