Description Usage Arguments Examples
Generate an asymmetric matrix with different fill values for top-left
and bottom-right triangles and along the diagonal as a
ggplot() object
1 2 3 4 5 6 7 8 9 10  | 
mapping | 
 Set of aesthetic mappings created by   | 
data | 
 The data to be displayed in this layer. There are three options:
If   | 
stat | 
 The statistical transformation to use on the data for this layer, as a string.  | 
position | 
 Position adjustment, either as a string, or the result of a call to a position adjustment function.  | 
... | 
 Other arguments passed on to   | 
na.rm | 
 If   | 
show.legend | 
 logical. Should this layer be included in the legends?
  | 
inherit.aes | 
 If   | 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21  | library(tibble)
library(ggplot2)
suppressMessages(library(dplyr))
tib <- tibble(
  g1 = c("A", "A", "B"),
  g2 = c("B", "C", "C"),
  val_1 = c(1, 2, 3),
  val_2 = c(-1, 0, 1)
)
tib
tib <- asymmetrise(tib, g1, g2)
tib$val_3 <- NA
tib$val_3[tib$g1 == tib$g2] <- c(1, 2, 3)
ggplot(tib, aes(x = g1, y = g2)) +
  geom_asymmat(aes(fill_tl = val_1, fill_br = val_2, fill_diag = val_3)) +
  scale_fill_br_gradient(low = "lightblue1", high = "dodgerblue") +
  scale_fill_tl_gradient(low = "lightpink", high = "tomato") +
  scale_fill_diag_gradient(low = "aquamarine", high = "forestgreen") +
  labs(fill_tl = "top-left fill", fill_br = "bottom-right fill")
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.