scale_linetype_manual出错

时间:2016-08-10 10:06:07

标签: r ggplot2 error-handling

我尝试使用ggplot2包来手动缩放线型。但是,我接受了这个错误,不知道出了什么问题。

示例:

group <- c("a", "b", "c")

ggplot() +
  geom_hline(aes(yintercept = 3, 
                 colour = group[1], 
                 linetype = group[1])) + 
  geom_hline(aes(yintercept = 2, 
                 colour = group[2], 
                 linetype = group[2])) + 
  geom_hline(aes(yintercept = 1, 
                 colour = group[3], 
                 linetype = group[3])) + 
  scale_colour_manual(name = "",
                      breaks = group, 
                      labels = c("This is group A", 
                                 "This is group B", 
                                 "This is group C"),
                      values = c("red", "purple", "gold")) + 
### until here everything works OK, but when I add scale_linetype_manual I get error
  scale_linetype_manual(name = "",
                        breaks = group, 
                        labels = c("This is group A", 
                                   "This is group B", 
                                   "This is group C"),
                        values = c("solied", "dotted", "dashed"))


Error in grid.Call.graphics(L_segments, x$x0, x$y0, x$x1, x$y1, x$arrow) : 
  invalid hex digit in 'color' or 'lty'

我的语法有错吗?或者,有没有更简单的方法来更改线型并将此更改包含在图例中?

0 个答案:

没有答案