coolbutuseless / ggsvg

Use SVG images as ggplot points
https://coolbutuseless.github.io/package/ggsvg/
Other
138 stars 5 forks source link

Creating a package on top of ggsvg #11

Open jimjam-slam opened 1 year ago

jimjam-slam commented 1 year ago

Hi Mike,

I'm maintaining ggflags, and I'm starting to hit a dead end with the SVG backend it uses (grImport2), which requires that I heavily pre-process my source images (flags).

I'm considering doing a 1.0 release with a different backend (which would make things like shifting our , and I'm evaluating ggsvg as a potential candidate.

If I were to build ggflags on top of ggsvg, I imagine the idea of it would be a geom_flag that:

  1. Take a two-letter country code as the flag aesthetic,
  2. Maps it to an included flag SVG file,
  3. Passes the content of that file to geom_point_svg with the country aesthetic.

I'm not super sure how that transformation from flag to country works, though. If aesthetics are directly applied to a layer, then geom_flag has access to the data and the mapping at the time the plot of defined, but if the flags are the only layer and aesthetics are defined globally, it doesn't.

I think I was hoping I could shortcut fully rewriting a ggplot2 extension package and avoid diving back into ggproto by just cheekily calling geom_point_svg directly, but this might not be the right approach. What do you think?