I was wondering whether it is possible to get the transformed data in ggplot2 graphs? In particular, I am interested in getting the coordinates and size of points in dot plots to use them in another plotting library (d3.js). How can I extract that information?
Here is the plot:
g=ggplot(data.frame(x=rnorm(100)), aes(x = x)) + geom_dotplot()
Now I can get the original data using g$data but I want the transformed data (coordinates of the points in the plot).
Thanks!
Use
ggplot_buildand then extract the data. Try this:The resulting object is a list, with the first element containing the data you’re after:
This is what it looks like:
PS. AFAIK, this feature only became available in
ggplot2version 0.9.0