Mastodon
Go back

geom_lollipop() by the Chartettes

UPDATE: Changed code to reflect the new horizontal parameter for geom_lollipop()

I make a fair share of bar charts throughout the day and really like switching to lollipop charts to mix things up a bit and enhance the visual appeal. They’re easy to do in ggplot2, just use your traditional x & y mapping for geom_point() and then use (you probably want to call this first, actually) geom_segment() mapping the yend aesthetic to 0 and the xend aesthetic to the same thing you used for the x aesthetic. But, that’s alot of typing. Hence, the need for geom_lollipop().

I’ll build this example from one provided by Stephanie Evergreen (that one’s in Excel). It’s not much code:

And, I’ll reiterate Stephanie’s note that the data is fake.

download

Compare it with it’s sister bar chart:

download1

to see which one you think works better (it really does come down to personal aesthetics choice).

You can find it in the development version of ggalt. The API is not locked in yet so definitely provide feedback in the issues.


Join the conversation:follow@hrbrmstr@rud.ison the fediverse to read and reply to this post from your own instance.

No comments yet.


Previous Post
Clandestine DNS lookups with gdns
Next Post
52Vis Week 2 (2016 Week #14) - Honing in on the Homeless