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.
| Diamond Prices | Glow-y Spiral |
|---|---|
| Milky Way Galaxy (6.1 million stars) |
|---|
| Airline Dataset (145 million points) | Methylation 450K Volcano Plot |
|---|---|
| U.S. Coronavirus Cases |
|---|
glow plots don’t depend on the order of points in the data (points are commutative and associative)
geom_point depending on settingstests/examples.r)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))