[R] Fwd: Question about paired plotting
John Kane
jrkrideau at inbox.com
Mon May 4 18:58:18 CEST 2015
Hi Luis,
Ah yes, that paper. I was rather shocked at what it implied :( People are still using dynamite plots, for heaven's sake! See http://biostat.mc.vanderbilt.edu/wiki/Main/DynamitePlots for some comments.
I see Jim has given you one way to do the plots you want. Here is another way using the ggplot2 package. You will probably have to install the package. The code below covers the 2B:2D plots.
####=======Install ggplot2===================
install.packages("ggplot2")
###======== plot desired graphs==================
library(ggplot2)
dat1 <- data.frame(x1 = rep("A", 4) , x2 = rep("B", 4), y1 = 5:8, y2 = 10:13)
p <- ggplot()
p1 <- p + geom_segment( aes(x = x1, y = y1, xend = x2, yend = y2)) +
geom_point(aes(x1, y1, colour = "blue", size = 2)) +
geom_point(aes(x2, y2, colour = "red", size = 2))
p1
p2 <- p1 + theme (legend.position = "none") +
xlab("Treatment") + ylab("Change Score")
p2
###======== end==================
We could have all the commands in one statement but it is easier to write the code this way to help in debugging (damn typos1) and so I left it to help you see what is happening.
For the lower plots, in ggplot2, you should have a look at geom_dotplot() . Here is an interesting demo of it in use. I like the addition of the median line in particular.
http://rstudio-pubs-static.s3.amazonaws.com/1406_947a49f2d7914dad8b0fd050a9df9858.html
John Kane
Kingston ON Canada
> -----Original Message-----
> From: luysgarcia at gmail.com
> Sent: Mon, 4 May 2015 04:52:51 -0300
> To: r-help at r-project.org
> Subject: [R] Fwd: Question about paired plotting
>
> Hello R experts,
>
> I just found a new paper which shows the proper way (according to the
> authors) to show data, specially paired. I am very interested in
> presenting
> this kind of data, specially the scatter plott. I have found a way to
> present it using this link:
>
> http://journals.plos.org/plosbiology/article?id=10.1371%2Fjournal.pbio.1002128#pbio.1002128.s007
>
> Nevertheless, I wanted to know if you know some example which allows me
> to
> produce a plot similar to the plots 2B-2D. I could do it by "hand" but it
> was quite time consuming and required editing the pictures,
>
> Many thanks for any help you can provide!
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
____________________________________________________________
FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!
More information about the R-help
mailing list