有谁知道我怎样才能在GGPLOT2传说的顺序控制?
从我所看到的顺序似乎与实际刻度标签,而不是规模声明顺序。 更改标题规模改变了排序。 我已经使用了钻石的数据集,以突出本作的一个小例子。 我试图用GGPLOT2一系列阴谋,我想使一个变量出现在他们所有的权利。 目前,虽然这只是发生在其中的一些,我就如何执行我想要的顺序,同时保留相应的刻度标签的损失。
library(ggplot2)
diamond.data <- diamonds[sample(nrow(diamonds), 1000), ]
plot <- ggplot(diamond.data, aes(carat, price, colour = clarity, shape = cut)) +
geom_point() + opts(legend.position = "top", legend.box = "horizontal")
plot # the legend will appear shape then colour
plot + labs(colour = "A", shape = "B") # legend will be colour then shape
plot + labs(colour = "Clarity", shape = "Cut") # legend will be shape then colour