[R] Sort data and symbol change in Jitter plot (ggplot2)

Luis Fernando García luysgarcia at gmail.com
Thu May 7 08:51:46 CEST 2015


Thanks all of you guys!

Your answers were very useful!

Thanks for the answer John, but I will try to keep the dotplot, but it is
very useful to know both techniques anyway :)

Petr, many thanks for your help, it was just what I needed, btw, the
arrangment based on the median was a headache for me! again, thanks!!!

2015-05-05 4:34 GMT-03:00 Luis Fernando García <luysgarcia at gmail.com>:

> Dear R experts,
>
> First than all I want to thank your expertise and for sharing your
> knowledge with the people who are starting.
>
> Recently I have been working on a new plot style (Jitterplot) but have
> still some issues when making two basic functions.
>
> First than all I want to change the symbol according to the prey type
> (presa) and not the color, I tried making, geom_dotplot(aes(fill = PRESA)
> but it did not work
>
> On a second hand I want to sort the plots from the highest to the lowest
> value, I tried by using reorder, but it did not work.
>
> Please find attached the dataset and the script.
>
> Thanks in advance!
>
> ####script######
>
> the dataset is attached
> library(ggplot2)
> p=read.table("paratropis.txt",header=T)
> attach(p)
> ggplot( data = p, aes(y = Tiempo, x = PRESA, reorder(PRESA, Tiempo,
> mean))) + # Move y and x here so than they can be used in stat_*
>   geom_dotplot(aes(shape = PRESA),
>                binaxis = "y",         # which axis to bin along
>                binwidth = 0.1,        # Minimal difference considered
> diffeerent
>                stackdir = "center"    # Centered
>   ) +
>   stat_summary(fun.y = mean, fun.ymin = mean, fun.ymax = mean,
>                geom = "crossbar", width = 0.5)
>
>
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list