diamonds <- jsonlite::fromJSON(
  "https://gw.alipayobjects.com/os/antvdemo/assets/data/diamond.json"
)

Rect

Recreation of this example.

g2(diamonds, asp(carat, price, color = clarity)) %>% 
  fig_point(
    asp(shape = "circle", size = 3),
    fillOpacity = 0.3, stroke = 0
  ) %>% 
  planes(~cut, type = "rect") %>% 
  motif(padding = c(32, 8, 48, 48))

Recreation of this example.

g2(diamonds, asp(carat, price, color = cut)) %>% 
  fig_point(
    asp(shape = "circle", size = 3),
    fillOpacity = 0.3, stroke = 0
  ) %>% 
  planes(~cut+clarity, type = "rect") %>% 
  motif(padding = c(32, 8, 48, 48))

List

Recreation of this example.

g2(diamonds, asp(carat, price, color = cut)) %>% 
  fig_point(
    asp(shape = "circle", size = 3),
    fillOpacity = 0.3, stroke = 0
  ) %>% 
  planes(
    ~cut, 
    type = "list",
    cols = 3,
    padding = 30
  ) %>% 
  motif(padding = c(32, 8, 48, 48))

Circle

library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union

df <- diamonds %>% 
  group_by(clarity, cut) %>% 
  summarise(
    price = sum(price)
  )
#> `summarise()` has grouped output by 'clarity'. You can override using the `.groups` argument.

total <- df %>% 
  group_by(clarity) %>% 
  summarise(
    total = sum(price)
  )

df <- df %>% 
  left_join(total, by = "clarity") %>% 
  mutate(price = (price / total))

g2(df, asp(y = price, color = cut)) %>% 
  fig_interval(
    adjust("stack"),
    stroke = "#fff", lineWidth = 2
  ) %>% 
  coord_type("theta", innerRadius = .2) %>% 
  planes(~clarity, type = "circle") %>% 
  gauge_x_linear(nice = FALSE)

Mirror

Recreation of this example

df <- data.frame(
  x = rep(1:50, 2),
  y = c(cars$speed, cars$dist),
  grp = rep(c("Speed", "Dist"), each = 50)
)

g2(df, asp(x, y, color = grp)) %>% 
  fig_interval() %>% 
  planes(
    ~grp, 
    padding = c(0, 48, 0, 0),
    type = "mirror", 
    transpose = TRUE
  ) %>% 
  motif(padding = c(32, 16, 48, 16))

Tree

g2(iris, asp(Petal.Width, Petal.Length, color = Species)) %>% 
  fig_point() %>% 
  planes(~Species, type = "tree")