Chapter 4 3D
4.1 Bar 3D
<- LETTERS[1:10]
v <- data.frame(
matrix x = sample(v, 300, replace = TRUE),
y = sample(v, 300, replace = TRUE),
z1 = rnorm(300, 10, 1),
z2 = rnorm(300, 10, 1),
color = rnorm(300, 10, 1),
size = rnorm(300, 10, 1),
stringsAsFactors = FALSE
%>%
) ::group_by(x, y) %>%
dplyr::summarise(
dplyrz1 = sum(z1),
z2 = sum(z2),
color = sum(color),
size = sum(size)
%>%
) ::ungroup()
dplyr matrix
## # A tibble: 92 × 6
## x y z1 z2 color size
## <chr> <chr> <dbl> <dbl> <dbl> <dbl>
## 1 A A 11.1 9.99 10.3 10.9
## 2 A B 40.7 42.1 46.4 42.0
## 3 A C 38.5 42.0 37.7 37.4
## 4 A D 18.0 19.1 21.3 20.2
## 5 A E 28.3 29.6 31.1 30.5
## 6 A F 18.1 19.5 19.3 21.1
## 7 A G 53.1 49.6 48.5 51.3
## 8 A H 21.2 20.4 18.5 20.4
## 9 A I 42.3 36.4 40.0 40.1
## 10 A J 21.8 18.8 19.8 20.7
## # … with 82 more rows
<- list(opacity = 0.4) # transparency
trans <- list(itemStyle = list(color = "#313695"))
emphasis
%>%
matrix e_charts(x) %>%
e_bar_3d(y, z1, stack = "stack", name = "Serie 1", itemStyle = trans, emphasis = emphasis) %>%
e_bar_3d(y, z2, stack = "stack", name = "Serie 2", itemStyle = trans, emphasis = emphasis) %>%
e_legend()
4.2 Scatter 3D
%>%
matrix e_charts(x) %>%
e_scatter_3d(y, z1, size, color) %>%
e_visual_map(
size,inRange = list(symbolSize = c(1, 30)), # scale size
dimension = 3 # third dimension 0 = x, y = 1, z = 2, size = 3
%>%
) e_visual_map(
color,inRange = list(color = c('#bf444c', '#d88273', '#f6efa6')), # scale colors
dimension = 4, # third dimension 0 = x, y = 1, z = 2, size = 3, color = 4
bottom = 300 # padding to avoid visual maps overlap
)