传奇不会显示

时间:2015-07-25 03:50:48

标签: r

问题已删除,不再适用。

1 个答案:

答案 0 :(得分:3)

这是一种方法,

nauyear <- c(2000, 2010, 2020, 2030, 2050)
naupop  <- c(14495, 17529, 25000, 25000, 25000)
naupopvsfs <- c(27400, 26000, 32300, 28700, 23600) 
naupopvsfslabels <- c("27.4%", "26%", "32.3%", "28.7%", "23.6%")
NAUPop <- data.frame(year = nauyear, population = naupop, 
                     vsfs = naupopvsfs, labels = naupopvsfslabels)

library(reshape2)
m <- melt(NAUPop, id = c("year", "labels"))

ggplot(m, aes(year, value, group=variable)) +
  geom_line(aes(linetype=variable, colour=variable)) +
  geom_point(aes(size=variable)) +
  geom_text(aes(label=labels), data=subset(m, variable == "vsfs")) +
  geom_text(aes(label=value), data=subset(m, variable == "population")) +
  scale_size_manual(values = c(1,2)) +
  scale_colour_manual(values = c("red", "blue")) +
  scale_linetype_manual(values = c("dashed", "solid"))