简体   繁体   中英

Customize lines in ggplot linegraph with multiple lines

I build this graph:

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())
 

在此处输入图像描述

But instead of changing the style of the lines, the styling just appears in the legend.

Thanks in advance for any kind of help.

cheers

take them out of the aes:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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