Skip to content

Instantly share code, notes, and snippets.

@andrewheiss
Created September 29, 2020 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewheiss/f419c2694aa6ca4a6aa10d7af89163d6 to your computer and use it in GitHub Desktop.
Save andrewheiss/f419c2694aa6ca4a6aa10d7af89163d6 to your computer and use it in GitHub Desktop.
library(tidyverse)
library(palmerpenguins)

avg_flipper <- penguins %>% 
  group_by(species) %>% 
  summarize(avg_flipper_length = mean(flipper_length_mm, na.rm = TRUE))
#> `summarise()` ungrouping output (override with `.groups` argument)

# Native horizontal geoms, but legend pointranges are still vertical
ggplot(avg_flipper, aes(x = avg_flipper_length, y = species, color = species)) +
  geom_pointrange(aes(xmin = 0, xmax = avg_flipper_length)) +
  labs(subtitle = "Native horizontal geoms, but legend pointranges are still vertical")

# ggstance horizontal geoms with horizontal legend pointranges
ggplot(avg_flipper, aes(x = avg_flipper_length, y = species, color = species)) +
  ggstance::geom_pointrangeh(aes(xmin = 0, xmax = avg_flipper_length)) + 
  labs(subtitle = "ggstance horizontal geoms with horizontal legend pointranges")

Created on 2020-09-29 by the reprex package (v0.3.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment