svglite + ggplot + customizability of output from ggplot2 side

131 views
Skip to first unread message

Alex Reynolds

unread,
Mar 9, 2017, 1:45:25 PM3/9/17
to ggplot2
When using svglite to export a ggplot object, are there any controls in ggplot2 which allow taking elements from a ggplot object and assigning them specific id values or group names, which can then be populated into the SVG output as ids or class names for elements or groups of elements in the SVG DOM? 

In other words, say I have a web service that can export an SVG of a ggplot to a div in my web browser, and I want to use d3.js to provide interactivity with the plot, I would use the d3.js API to access elements in the SVG DOM via class or id names. 

Are there any calls in the ggplot2 API that programmatically offer unique id values or group names for primitives/objects or groups of primitives/objects inside a plot — lines, points, rects, etc., which can translate over to the svglite output?

I think third-party offerings like plot.ly offer interactivity with plots, but I'm looking to use d3.js directly for an internal project, however. Thanks for any advice!

Regards,
Alex

Hadley Wickham

unread,
Mar 15, 2017, 4:55:47 PM3/15/17
to Alex Reynolds, ggplot2
Unfortunately not, because svglite is a generic R graphics device, and
there's no way to pass that information through R's graphics rendering
pipeline.

Hadley
> --
> --
> 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.



--
http://hadley.nz

Joyce Robbins

unread,
Mar 19, 2017, 7:58:32 AM3/19/17
to Hadley Wickham, Alex Reynolds, ggplot2
I haven't tried it so I don't know if it does what you want, but I came across the gridSVG package which might be of help:


Joyce

> To unsubscribe: email ggplot2+unsubscribe@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
--
--
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

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+unsubscribe@googlegroups.com.

Alex Reynolds

unread,
Mar 19, 2017, 4:58:47 PM3/19/17
to Joyce Robbins, Hadley Wickham, ggplot2
This looks promising, thanks very much for the pointer!
Reply all
Reply to author
Forward
0 new messages