Skip to content

Instantly share code, notes, and snippets.

@bbest
Last active October 17, 2017 21:57
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 bbest/db0ff8d37f98afe7a657f055732c3630 to your computer and use it in GitHub Desktop.
Save bbest/db0ff8d37f98afe7a657f055732c3630 to your computer and use it in GitHub Desktop.
try whisker plots on uncertainty estimates
# try whisker plots on uncertainty estimates
library(tidyverse)
d = tribble(
~sp, ~source, ~n, ~cv,
'hw', '1999 Smith', 10400, 0.138,
'hw', '2003 Stevick', 11570, 0.068,
'hw', '2012 Palka', 335, 0.42,
'hw', '2016 Roberts', 1633, 0.07,
'lbw', '2006 Barlow', 1007, 1.25,
'lbw', '2013 Bradford', 4571, 0.65,
'lbw', '2017 Bradford', 7619, 0.66)
d = d %>%
mutate(
n_min = n - n*cv,
n_max = n + n*cv,
pct200 = round(200 / n * 100, 1)) %>%
arrange(sp, desc(source))
d
ggplot(d %>% filter(sp=='hw'), aes(source, n, ymin=n_min, ymax=n_max)) +
geom_pointrange() + coord_flip() +
theme_minimal() +
theme(
axis.text.x = element_text(angle=50),
axis.text.y = element_text(angle=50),
axis.title.x = element_blank(), # , vjust=0.5, size=16
axis.title.y = element_blank()) # , vjust=0.5, size=16
ggsave('hw_cv.pdf', w=2, h=2, u='in')
ggplot(d %>% filter(sp=='lbw'), aes(source, n, ymin=n_min, ymax=n_max)) +
geom_pointrange() + coord_flip() +
theme_minimal() +
theme(
axis.text.x = element_text(angle=50),
axis.text.y = element_text(angle=50),
axis.title.x = element_blank(), # , vjust=0.5, size=16
axis.title.y = element_blank()) # , vjust=0.5, size=16
ggsave('lbw_cv.pdf', w=2, h=2, u='in')
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment