r - Getting legends with dashed line in ggplot when errorbars are solid -
this question has answer here:
- removing layer legend in ggplot 1 answer
i'm having difficulty getting legend behave want when ggplot errorbars. errorbars ridiculous dashed line force solid one, unfortunately results in legend forgets dashed property.
there several similar so-questions haven't found address particular problem (this 1 closest, another similar can found here). hadley did gave answer 2010 on similar question on r-help list i'm not sure how implement it, seems lot of work have 4 lines , 2 facets in actual plot.
test code
set.seed(1) test_df <- data.frame(models = rep(paste("model", letters[1:3]), 3), x = c(rep(1, 3), rep(2, 3), rep(3, 3)), y = c(1:3,1:3+1+rnorm(3,0,.2),1:3+2)+rnorm(3,0,.3)) test_df$ymax <- test_df$y + .3 test_df$ymin <- test_df$y - .3 ggplot(test_df, aes(x=x, y=y, color=models, linetype=models)) + geom_line() + geom_errorbar(aes(ymax=ymax, ymin=ymin), linetype=1, lwd=1.2, width=.5)
ha, had given , post question stumbled upon this question - turns out guide="none"
or guide=false
had tried not correct option, key in show_guide
option:
ggplot(test_df, aes(x=x, y=y, color=models, linetype=models)) + geom_line() + geom_errorbar(aes(ymax=ymax, ymin=ymin), linetype=1, lwd=1.2, width=.5, show_guide=false)
Comments
Post a Comment