gg1 <- ggplot(data = data.frame(x,y,z), aes(x=x,y=y,color = z,shape =z,fill = z)) + geom_point() +
scale_shape_manual(values=c(11:20))
Note: we need the scale shape manual because we have more than 6 levels for shape. I forgot to do this in my orginal example (my apologies for this).
Can I not manipulate the following matrices and recover the mapping between colour and the levels of z?
> ggplot_build(gg1)$data[1]
[[1]]
shape colour fill x y PANEL group size alpha stroke
1 16 #00BFC4 #00BFC4 1 0.29579631 1 4 1.5 NA 0.5
2 12 #D89000 #D89000 2 -0.43358638 1 8 1.5 NA 0.5
3 20 #FF62BC #FF62BC 3 -0.09725683 1 20 1.5 NA 0.5
4 15 #00BF7D #00BF7D 4 0.90603884 1 23 1.5 NA 0.5
5 17 #00B0F6 #00B0F6 5 -0.62904424 1 29 1.5 NA 0.5
6 18 #9590FF #9590FF 6 -1.07468368 1 37 1.5 NA 0.5
7 12 #D89000 #D89000 7 -1.23907191 1 40 1.5 NA 0.5
8 14 #39B600 #39B600 8 -0.40183759 1 49 1.5 NA 0.5
9 13 #A3A500 #A3A500 9 2.17610186 1 55 1.5 NA 0.5
10 16 #00BFC4 #00BFC4 10 -0.16761590 1 63 1.5 NA 0.5
11 20 #FF62BC #FF62BC 1 -0.55441511 1 7 1.5 NA 0.5
12 16 #00BFC4 #00BFC4 2 -0.91594616 1 12 1.5 NA 0.5
13 15 #00BF7D #00BF7D 3 0.30314967 1 17 1.5 NA 0.5
14 19 #E76BF3 #E76BF3 4 0.38348840 1 26 1.5 NA 0.5
15 14 #39B600 #39B600 5 -0.01784608 1 27 1.5 NA 0.5
16 15 #00BF7D #00BF7D 6 -0.82852709 1 35 1.5 NA 0.5
17 17 #00B0F6 #00B0F6 7 1.00782650 1 43 1.5 NA 0.5
18 12 #D89000 #D89000 8 0.45755324 1 47 1.5 NA 0.5
19 13 #A3A500 #A3A500 9 -0.02577137 1 55 1.5 NA 0.5
20 20 #FF62BC #FF62BC 10 0.85958394 1 65 1.5 NA 0.5
21 12 #D89000 #D89000 1 -0.06696429 1 2 1.5 NA 0.5
or the following matrix ?
> ggplot_build(gg1)$plot[[4]]
* x -> x
* y -> y
* colour -> z
* shape -> z
* fill -> z
>
Which object contains the mapping between the levels of z and the colour assigned to it ?
Best Regards,
Ashim.