Learn R Programming

glow (version 0.13.0)

relxy: relxy

Description

Helper functions for specifying the `radius` parameter in `GlowMapper$map` and similar.

Usage

relx(r, mode = "data")

rely(r, mode = "data")

Value

A class structure for input to `GlowMapper$map`

Arguments

r

Radius of point data relative to X or Y range of the plot, a value between 0 and 1.

mode

One of "data" (default) or "plot". Whether to use a radius relative to the extent of the data range or the plot range (which could have been adjusted manually).

Details

Helper functions for specifying the `radius` parameter relative to the range of the plot as a proportion. I.e., a value of 0.02 corresponds to 2

Examples

Run this code

gm <- GlowMapper$new(xdim=480, ydim=240, blend_mode = "additive", nthreads=4)

gm$map(x=1:10, y=runif(10)*100, radius=relx(0.01), intensity = 1)
pd <- gm$output_dataframe(saturation = 1)

ggplot() +
  geom_raster(data = pd, aes(x = x, y = y, fill = value), show.legend=FALSE) +
  coord_fixed(gm$aspect(), xlim = gm$xlim(), ylim = gm$ylim()) +
  scale_fill_gradientn(colors = additive_alpha(viridisLite::viridis(12))) +
  theme_night()

# Relative radius to y-range
gm$map(x=1:10, y=runif(10)*100, radius=rely(0.01))
pd <- gm$output_dataframe(saturation = 1)
ggplot() +
  geom_raster(data = pd, aes(x = x, y = y, fill = value), show.legend=FALSE) +
  coord_fixed(gm$aspect(), xlim = gm$xlim(), ylim = gm$ylim()) +
  scale_fill_gradientn(colors = additive_alpha(viridisLite::viridis(12))) +
  theme_night()

Run the code above in your browser using DataLab