如何更改GGPLOT2线与面的颜色?(How to change line and shape co

2019-06-26 19:33发布

我有这样一个数据帧:

x <- data.frame(time = c('1', '2', '3'), perc = c(0.2, 0.4, 0.6, 0.3, 0.55, 0.69, 0.2, 0.22, 0.35), type=c(rep('a', 3), rep('b', 3), rep('c', 3)))

而要想做到这样的(下图)的阴谋,但使用这些不同的颜色c('#0023a0', '#f9a635', '#bebec0')

ggplot(x, aes(time, perc, group=type, colour=type, shape=type)) + geom_point(size=4) + geom_line(size=1)

我已经尝试用不同的方式scale_colour_huescale_shape_discretescale_fill_manual ,但没有成功。

Answer 1:

你究竟什么尝试? 这似乎为我工作:

ggplot(x, aes(time, perc, group = type, pch = type, colour = type)) + 
  geom_point() +
  geom_line() +
  scale_colour_manual(values= c('#0023a0', '#f9a635', '#bebec0'))



文章来源: How to change line and shape colours in ggplot2?
标签: r ggplot2