Re: [R] Adding a legend to a (multi-facet) plot produced by ggplot().

2019-12-01 Thread Rui Barradas
Hello, Here are two ways of drawing the lines black and at the same time removing the lines in the legend. The second way is more idiomatic. 1. Override the colour setting in the ggplot call when drawing the lines: geom_line(aes(y = y1), colour = "black") + 2. Don't set the colour aestheti

Re: [R] Adding a legend to a (multi-facet) plot produced by ggplot().

2019-12-01 Thread Rolf Turner
On 2/12/19 5:08 pm, Rui Barradas wrote: Hello, Here are two ways of drawing the lines black and at the same time removing the lines in the legend. The second way is more idiomatic. 1. Override the colour setting in the ggplot call when drawing the lines: geom_line(aes(y = y1), colour = "bla

Re: [R] Adding a legend to a (multi-facet) plot produced by ggplot().

2019-12-01 Thread Rolf Turner
On 2/12/19 3:03 am, Rui Barradas wrote: Hello, See if this is it. The standard trick is to reshape the data from wide to long, see the SO post [1]. Then add a scale_shape_* layer to the plot. yyy <- cbind(xxx, y3 = y3) long <- reshape2::melt(yyy, id.vars = c("x", "y1", "grp")) ggplot(lon

Re: [R] Adding a legend to a (multi-facet) plot produced by ggplot().

2019-12-01 Thread Antony Unwin
lour=type, shape=type)) + geom_point() + geom_abline(intercept=3, slope=2) + facet_grid(rows=vars(type), cols=vars(grp)) + scale_colour_manual(values=c("blue", "red")) + scale_shape_manual(values=c(20,3)) Antony Unwin University of Augsburg, Germany > From: Rolf Turne

Re: [R] Adding a legend to a (multi-facet) plot produced by ggplot().

2019-12-01 Thread Jeffrey Pullin
Hi Rolf, Some code to produce the plot you want is here: https://gist.github.com/jeffreypullin/be752f11a136601ffecddc73ba0519b9 Hope you find it helpful. Personally I have found that the key to effective ggplot2 use is getting your data into the right format (one data.frame, tidy style) before

Re: [R] Adding a legend to a (multi-facet) plot produced by ggplot().

2019-12-01 Thread Rui Barradas
Hello, See if this is it. The standard trick is to reshape the data from wide to long, see the SO post [1]. Then add a scale_shape_* layer to the plot. yyy <- cbind(xxx, y3 = y3) long <- reshape2::melt(yyy, id.vars = c("x", "y1", "grp")) ggplot(long, aes(x, y = value, colour = variable, shap

[R] Adding a legend to a (multi-facet) plot produced by ggplot().

2019-11-30 Thread Rolf Turner
I have been struggling to add a legend as indicated in the subject line, with no success at all. I find the help to be completely bewildering. I have attached the code of what I have tried in the context of a simple reproducible example. I have also attached a pdf file of a plot produced with