I'm trying to make a mosaic plot with the vcd
package, and i'm having an hard time understanding how to configure some settings of the plot.
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"))
The legend of the different levels of the A variable are on the top of the plot, which is not ver helpful since the category "a", of variable B does not have all those levels. I would like the legend to be in the bottom to be together with the category that has all the levels in the legend.