On geom_point() : Not to "dodge", not to "jitter, but to slide

254 views
Skip to first unread message

Cy Mallon

unread,
Dec 14, 2015, 6:25:32 AM12/14/15
to ggplot2
Hello Everyone,

I'm making a bubble plot of species abundance data before and after an experimental treatment. To do this, I've created a bubble plot where the abundances before (day 0) and after (day 28) are overlaid with one another. If you can see the .pdf I've posted, it's clear the abundances shrink from Day 0 to Day 28. 

As of now, the before and after bubbles are directly centered upon each other. However, what I would like to so is shift the after (i.e., Day 28) bubble to the bottom of the before bubble (i.e., Day 0). That way the bubble are not directly centered upon each other, but their southern most point begins on the same line. 

Is this possible with jitter or dodge? Or is there another function I should use?

Thanks so much,

Cyrus


bubble.plot.teaser.pdf

Roman Luštrik

unread,
Dec 14, 2015, 6:46:15 AM12/14/15
to Cy Mallon, ggplot2
Hi,

you would have to calculate by hand the distance moved. In case you haven't already, make sure you scale the size of bubble by area (http://docs.ggplot2.org/current/scale_area.html), not radius, or, use a different plot. For comparing different treatments, a simple line graph my be superior to most other representations.

Cheers,
Roman

--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
 
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2

---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
In God we trust, all others bring data.

Cyrus A. Mallon

unread,
Dec 14, 2015, 7:34:02 AM12/14/15
to Roman Luštrik, ggplot2
Hi Roman,

Thanks for you quick reply. I line graph might be better, but in this case I think the overlaid bubbles help condense the data and provide an easy representation of which species were found in particular treatments--in many ways it's like looking at a rubric chart. Also, I have scaled by area ;)

I'm still a little lost as to how I can shift the bubbles. (I'm quite new to R and ggplot2.) What is there reference I use to calculate the distance move if my y-axis is a categorical variable? And would I use the position_dodge() function to somehow shift vertically?

Kindly,

Cyrus

Roman Luštrik

unread,
Dec 14, 2015, 7:56:19 AM12/14/15
to Cyrus A. Mallon, ggplot2
I don't think you can do that automagically. From what I know, you would have to change species from factor to numeric and add/substract some value to reflect the "slide". This of course means you will have to coerce the numeric y axis to look like factor (define breaks/labels).

Unless I'm missing something, in which case I'm sure people more knowledgeable than me will chime in.

Cheers,
Roman

Hadley Wickham

unread,
Dec 14, 2015, 11:48:54 AM12/14/15
to Roman Luštrik, Cyrus A. Mallon, ggplot2
You can use position nudge in the dev version (which I'm submitting to
CRAN later today)
Hadley
http://had.co.nz/

Cyrus A. Mallon

unread,
Dec 14, 2015, 12:13:28 PM12/14/15
to Hadley Wickham, Roman Luštrik, ggplot2
Super! I'll check it out.
Thank you,
Cyrus

Cy Mallon

unread,
Jul 17, 2016, 6:42:40 PM7/17/16
to ggplot2, roman....@gmail.com, cyrus...@gmail.com
Hi All,
I know it's been a while, but I'm only coming back to this now. Can I still use position_nudge() if my axis is made up of strings? I like to make sure these pairs of overlaid bubble start from the same y position. Any ideas?
Cheers,
Cyrus
bubble_plots_17July2016.pdf
Reply all
Reply to author
Forward
0 new messages