[英]Coloring one linetype in geom_line (ggplot2)
您實際上必須添加一種color
(或多種colour
)
ggplot(df,
aes(
x = games1,
y = diff_cum,
group = Year,
color = Year, # This right here!
linetype = Year)) +
geom_line(size = 1) +
theme_bw() +
scale_color_manual(values = c("my","colours","for","year"))
您可以使用ifelse
設置aes組
ggplot(mtcars, aes(x = disp, y = hp, group = cyl)) +
geom_line(aes(color = ifelse(cyl == 6, "6", "not6"))) +
scale_color_manual(values = c("red", "black"))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.