rensa.co | projects

ggflags

A package for plotting country flags as bubbles or balloons in ggplot.

I’ve taken over development of ggflags, an extension to ggplot2 that allows you to plot country flags as points or bubbles. The original was developed by Baptiste’s Auguié, and I’ve so far extended it to use round, vector flags from the EmojiOne v2 set (so they’ll look great at any size).

We’re currently working on SVG export for interactive graphics. It works with ggsave if you have the svglite package installed, although you lose the structure of the plot, which isn’t great for interactive applications. gridSVG::grid.export also works, although you’ll have to do some manual tweaking of the output to correct for a bug with the viewport.

Current known issues:

  • When exporting with gridSVG::grid.export, the viewport doesn’t always line up wit the plot properly. This can be corrected by manually tweaking the SVG output.
  • When exporting with ggsave, flags that overlap the edges of the plot area don’t properly clip o nthe boundary. You can pad the plot with expand to mitigate this.
  • Strokes aren’t currently scaling with size properly, but I’m working on it!

If you think you can help me work out these issues, or think the package could do other things, feel free to open an issue or open a pull request! I’m particularly interested in creating a separate package to plot arbitrary sets of SVG icons.

James Goldie

PhD student (climate change + health). I also code and build things for fun and for social change.

Read Next

Is It Hot Right Now?