scale_linetype_manual异常行为

时间:2018-11-07 16:13:27

标签: r ggplot2

对于创建带有线型和颜色herehere的混合图例的问题,我发现了看似正确的解决方案。但是,我的代码仍然没有预期的效果,而是生成了一个图例,其中未考虑线型。我的目标是让我的传说与我的情节相符。

我从一个简单的scale_linetype_manual("",value = c(2,2,1,1,1))开始,并在下面的代码中停止尝试。

ggplot(data_norm_long, aes(x = as.integer(year), y = value, colour = variable, linetype = kat), group = "variable") +
    geom_point() +
    geom_line() +
    scale_color_manual("",
    breaks = c("LO_kat2","lean_kat2","hola_kat1","lean_kat1","LO_kat1"),
    values = c(LO_kat2 = "darkblue", lean_kat2 = "darkgreen", hola_kat1 = "darkred", lean_kat1 = "darkgreen", LO_kat1 = "darkblue"),
    labels = c("Label 1","Label 2","Label 3","Label 4","Label 5")) +
    scale_linetype_manual("",
                          breaks = c("LO_kat2","lean_kat2","hola_kat1","lean_kat1","LO_kat1"),
                          values = c("1" = "solid", "2" = "dashed"))

图:

Current plot(显然我不允许嵌入图像。)

0 个答案:

没有答案