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

Luis Fernando García luysgarcia at gmail.com
Tue May 5 09:34:10 CEST 2015

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!


the dataset is attached
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
               stackdir = "center"    # Centered
  ) +
  stat_summary(fun.y = mean, fun.ymin = mean, fun.ymax = mean,
               geom = "crossbar", width = 0.5)
-------------- next part --------------
Ara�a	PRESA	TAMA�O	Tiempo		
Ara1	L.lepi	peque�o	255506		
Ara2	L.passa	grande	439724		
Ara3	L.cicin	peque�o	408377		
Ara3	L.passa	grande	268235		
Ara3	L.passa	peque�o	419578		
Ara3	L.rute	peque�o	427730		
Ara3	L.lepi	grande 	351840		
Ara4	L.cicin	peque�o	548918		
Ara4	L.passa	peque�o	438361		
Ara4	L.rute	grande 	903518		
Ara4	L.rute	peque�o	359928		
Ara4	L.lepi	grande 	332754		
Ara4	L.lepi	peque�o	267759		
Ara6	L.rute	peque�o	227514		
Ara7	L.cicin	peque�o	494398		
Ara7	L.passa	grande	218080		
Ara7	L.rute	grande 	485121		
Ara7	L.rute	peque�o	498692		
Ara7	L.lepi	grande 	248303		
Ara7	L.lepi	peque�o	101027		
Ara8	L.lepi	grande 	320952		
Ara9	L.cicin 	grande	334014		
Ara9	L.cicin	peque�o	232391		
Ara9	L.passa	peque�o	447254		
Ara9	L.rute	grande 	533385		
Ara9	L.rute	peque�o	864524		
Ara9	L.lepi	grande 	282418		
Ara9	L.lepi	peque�o	169500		
Ara10	L.cicin 	grande	476236		
Ara10	L.cicin	peque�o	377899		
Ara10	L.rute	peque�o	426247		
Ara11	L.passa	grande	286441		
Ara11	L.rute	peque�o	544675		
Ara11	L.lepi	grande 	397056		
Ara12	L.passa	grande	217148		
Ara12	L.rute	grande 	438068		
Ara12	L.lepi	grande 	389474		
Ara14	L.cicin 	grande	513290		
Ara14	L.passa	grande	356091		
Ara15	L.cicin	peque�o	511906		
Ara16	L.cicin	peque�o	790962		
Ara16	L.passa	grande	507399		
Ara16	L.rute	peque�o	298853		
Ara17	L.cicin 	grande	468640		
Ara17	L.rute	peque�o	392512		
Ara18	L.rute	peque�o	473115		
Ara19	L.cicin 	grande	578176		
Ara19	L.cicin	peque�o	479934		
Ara19	L.passa	peque�o	319707		
Ara19	L.rute	grande 	347096		
Ara21	L.cicin 	grande	546950		
Ara23	L.cicin 	grande	371814		
Ara23	L.passa	grande	287769		
Ara23	L.passa	peque�o	281093		
Ara23	L.rute	grande 	429621		
Ara23	L.lepi	grande 	208509		
Ara24	L.cicin 	grande	393763		
Ara25	L.cicin 	grande	469052		
Ara25	L.lepi	grande 	410563		
Ara25	L.lepi	peque�o	439584		
Ara26	L.cicin	peque�o	485701		
Ara26	L.rute	grande 	391971		
Ara27	L.cicin 	grande	491197		
Ara28	L.passa	peque�o	308984		
Ara29	L.lepi	peque�o	472830		
Ara30	L.passa	peque�o	249036		
Ara31	L.passa	grande	217148		
Ara31	L.passa	peque�o	212454		
Ara31	L.lepi	peque�o	234619		
Ara32	L.passa	peque�o	230255		
Ara32	L.lepi	peque�o	297512		
Ara34	L.rute	grande 	352213		
Ara34	L.passa	peque�o	191547		
Ara34	L.lepi	peque�o	201616		
Ara36	L.lepi	grande 	411587		

More information about the R-help mailing list