How to get a black outline on points and select specific brewer colours

32 views
Skip to first unread message

Danielle Hudson

unread,
Jan 23, 2020, 7:15:27 PM1/23/20
to estimationstats
Hi there,

I'm currently struggling to figure out how to get a black outline around the points in the raw plot. I noticed in this tweet (see attached photo) the authors have the outline on their points, so I'm wondering if you know what bit of code is necessary (I'm working in R). The standard pch= 2, lwd =3 and so on produces errors.

My current code for plots:
plot(multi.group, color.column= WD, rawplot.ylabel = "NEE", effsize.ylabel = "Difference in NEE", axes.title.fontsize = 8, palette = "Dark2", pch= 24, lwd= 2)


While I'm at it I'll also ask, is there a way to select certain colours from a colour brewer palette? The ggplot approach hasn't worked for me yet, i.e. (4, "Dark2") [2:4].


Thanks in advance!!
Danielle
Screen Shot 2020-01-22 at 10.36.03 AM.png

Adam Claridge-Chang

unread,
Jan 24, 2020, 12:34:17 AM1/24/20
to estimationstats
Hi Danielle,

Thanks for your note.

I'm pretty sure that image was generated by a custom R script, derived from dabestr, that was written for an article in that issue of eNeuro.

I'll let Joses or someone else answer if there is a way to do with the standard libraries, and the palette question.

best,
Adam

Danielle Hudson

unread,
Jan 27, 2020, 8:56:47 AM1/27/20
to estimationstats
Ok! Thanks for your time.

Danielle

Joses Ho

unread,
Jan 28, 2020, 10:00:39 PM1/28/20
to estimationstats
Hi Danielle,

If you have specific question for the dabestr package, you should post at the Github issues tracker instead. (This forum is specifically for users of the webapp, as well as general questions about estimation stats.) Nonetheless, happy to answer you here.

I'm currently struggling to figure out how to get a black outline around the points in the raw plot. I noticed in this tweet (see attached photo) the authors have the outline on their points, so I'm wondering if you know what bit of code is necessary (I'm working in R). The standard pch= 2, lwd =3 and so on produces errors.


While Adam is correct about the image in the tweet being post-processed, you can achieve what you want. As noted in the help for plot.dabest (simply run help(plot.dabest)) in the R console, the swarmplot.params keyword argument allows you to supply a list of keyword-value pairs that are passed along to geom_point. (You can also access the dabestr documentation at rrdr.io.)

So, modifiying your line to

plot(multi.group, color.column= WD,
     rawplot.ylabel = "NEE", effsize.ylabel = "Difference in NEE",
     axes.title.fontsize = 8, palette = "Dark2",
     swarmplot_params=list(pch=24, lwd=2))

should give you what you want. (Although to properly recreate the image from the tweet you want to use swarmplot_params=list(pch=1, lwd=3))

While I'm at it I'll also ask, is there a way to select certain colours from a colour brewer palette? The ggplot approach hasn't worked for me yet, i.e. (4, "Dark2") [2:4].

Currently, this is not possible; it only accepts palettes that are passed directly to ggplot2::scale_color_brewer(). This should be fixed in the future, although I cannot say when...!

Hope this helps,
Joses

Danielle Hudson

unread,
Jan 29, 2020, 2:49:34 PM1/29/20
to estimationstats
Amazing thank you, problem solved! I didn't realize the distinction with the forums, I'll ensure I post on GitHub next time. 

Thanks,
Danielle
Reply all
Reply to author
Forward
0 new messages