我试图将我的 ggplot 中的一行从破折号改为虚线,但我失败了,函数 scale_linetype_manual 不起作用。谁能帮我解决这个问题?
ggplot(d, aes(a,value)) +
geom_line(aes(color = series), size=2)+
scale_y_continuous(breaks=seq(-2.5, 2.5, 2.5)) +
coord_cartesian(ylim=c(-2.5, 2.5))+
scale_x_continuous(breaks=seq(-200, 2000, 1000)) +
scale_color_manual(values=c("#E69F00","#56B4E9", "#56B4E9")) +
scale_linetype_manual(values=c("twodash", "dotted", "dotted")) +
theme(legend.direction = 'vertical',
legend.position = 'right',
legend.key = element_rect(size = 7),
legend.key.size = unit(3, 'lines'))+
theme(panel.grid.major = element_blank(), text = element_text(size=30),
panel.grid.minor = element_blank(),
panel.background = element_blank(), axis.line = element_line(colour =
"black"))+
geom_vline(xintercept=c(0), linetype="dotted", size=1.5)+
geom_rect(data=rect, aes(xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax),
color="gray55",
alpha=0.4,
inherit.aes = FALSE)+
labs(x = "time [ms]",
y = "Amplitude [µV]",
color = "")
Run Code Online (Sandbox Code Playgroud)
您的情节的“问题”在于您没有将美学映射linetyppe
到变量。因此,您的调用scale_linetype_manual无效。您应该将代码更改为
ggplot(d, aes(a,value)) +
geom_line(aes(color = series, linetype = series), size = 2) +
...
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4431 次 |
| 最近记录: |