繁体   English   中英

用多条线自定义ggplot线图中的线

[英]Customize lines in ggplot linegraph with multiple lines

我构建了这个图表:

labels.minor <- c("nie","selten","manchmal", "mehrmals", "oft", "sehr oft", "immerzu")

df_ebf <- df_ebf %>%
  map_df(rev)


ggplot(data=df_ebf, aes(x=forcats::fct_inorder(Skalen), y=Werte, group="")) +
  geom_line(aes(y = Werte, color = "#003560")) +
  geom_line(aes(y = SD_plus, color = "#8DAE10", linetype = "dashed")) +
  geom_line(aes(y = SD_minus, color = "#8DAE10",linetype = "dashed")) +
  geom_point(color = "#003560") +
  coord_flip() +
  labs(x="EBF-Skalen") +
  scale_y_continuous(limits = c(0, 6), breaks = c(0,1,2,3,4,5,6), labels = paste0(0:6, "\n", labels.minor), sec.axis = sec_axis(~.x, breaks = 0:6)) +
  scale_x_discrete(expand = c(0,0)) +
  theme(panel.grid.major.y = element_blank(),panel.grid.minor.x = element_blank(),axis.line.x = element_line(size = 1, colour = "black", linetype=1),axis.title=element_blank())
 

在此处输入图像描述

但不是改变线条的样式,样式只是出现在图例中。

提前感谢您的任何帮助。

干杯

将它们从 aes 中取出:

aes(...), color="..", linetype=".."

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM