【发布时间】:2020-11-17 13:47:29
【问题描述】:
我想画出掷两个非常规六面骰子的所有可能结果:
die_1 <- c(0, 1, 2, 3, 6, 6)
die_2 <- c(0, 0, 0, 6, 6, 6)
每个排列的骰子掷得更高的颜色。
结果如下所示:
到目前为止,我已经尝试过:
library(tidyverse)
expand_grid(die_1, die_2) %>%
mutate(winner = if_else(die_1 > die_2, "die_1", if_else(die_1 == die_2, "draw", "die_2"))) %>%
ggplot(aes(x = die_1, y = die_2, fill = winner)) +
geom_point(aes(colour = winner), size = 10, shape = "square") +
scale_discrete_manual(aesthetics = "colour", values = c("orange", "blue", "grey")) +
scale_y_reverse(breaks = c(0:6)) +
scale_x_continuous(position = "top", breaks = c(0:6))
imgur 我的 ggplot2 版本
所以我试图将 permutations 放在 x 和 y 轴上,但 ggplot2 绘制 结果,这会产生过度绘图。如果我不解释自己,请比较图片。
有谁知道如何在 ggplot2 中实现这一点?
【问题讨论】:
标签: r ggplot2 permutation dice