我正在尝试使用vcd
包制作马赛克图,但我很难理解如何配置图的某些设置。
library(vcd)
library(RColorBrewer)
mydf <- structure(list(A=structure(c(7L,6L,7L,6L,7L,1L,5L,4L,7L,6L,6L,6L,6L,6L,
3L,6L,6L,6L,5L,3L),
.Label=c("a","b","c","d","e","f","g","h","i"),
class="factor"),
B=structure(c(3L,2L,1L,1L,3L,3L,3L,3L,2L,3L,3L,1L,3L,
3L,3L,3L,3L,3L,3L,3L),
.Label=c("a","b","c"),
class="factor")),
.Names=c("A","B"),
row.names=c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L,
10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L),
class="data.frame")
mosaic( ~ A + B, data=mydf, highlighting="A",
highlighting_fill=brewer.pal(9, "Set3"))
A 变量的不同级别的图例位于图的顶部,这不是很有帮助,因为变量 B 的类别“a”没有所有这些级别。我希望图例与图例中所有级别的类别一起位于底部。