ggplot_to_magiceye: Convert a ggplot2 object to a 3D autostereogram

Description Usage Arguments Value Examples

View source: R/plot-to-magiceye.R

Description

Convert a 2ggplot2 object to a 3D autostereogram. Set dot colors used in final image.

Usage

1
2
3
4
5
6
ggplot_to_magiceye(
  ggobj,
  colors = c("#00436b", "#ffed89"),
  height = 6,
  width = 6
)

Arguments

ggobj

A ggplot object.

colors

Array of at least 2 color hex codes. Colors should be visually distinct and avoid using too many.

height

Height of output matrix. Larger values take longer to render, but will have more detail.

width

Width of output matrix. Larger values take longer to render, but will have more detail.

Value

A raster matrix for plot().

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
df <- data.frame(
group = c("Dog", "Cat", "Mouse"),
value = c(25, 30, 50)
)

library(ggplot2)
ggplot(df, aes(x="", y=value, fill=group))+
  geom_bar(width = 1, stat = "identity") +
  coord_polar(theta="y") -> pp

pp %>% ggplot_to_magiceye() %>% plot()

ryantimpe/MagicEye documentation built on April 12, 2021, 5:59 p.m.