1 误差棒图

1.1 errorbar

Code
corr_res <- map(mtcars %>% select(-mpg), cor.test, y = mtcars$mpg)
library(broom)

corr_res %>% 
    map_dfr(tidy, .id = "predictor") %>% 
    ggplot(aes(x = fct_reorder(predictor, estimate))) + 
    geom_point(aes(y = estimate)) + 
    geom_errorbar(aes(ymin = conf.low, ymax = conf.high), width = .1) +
    labs(x = NULL, y = "Correlation with mpg")

1.2 linerange

Code
corr_res %>% 
    map_dfr(tidy, .id = "predictor") %>% 
    ggplot(aes(x = fct_reorder(predictor, estimate))) + 
    geom_point(aes(y = estimate)) + 
    geom_linerange(aes(ymin = conf.low, ymax = conf.high)) +
    labs(x = NULL, y = "Correlation with mpg")

1.3 pointrange

Code
corr_res %>% 
    map_dfr(tidy, .id = "predictor") %>% 
    ggplot(aes(x = fct_reorder(predictor, estimate))) + 
    geom_pointrange(aes(y = estimate, ymin = conf.low, ymax = conf.high)) +
    labs(x = NULL, y = "Correlation with mpg")

1.4 crossbar

Code
corr_res %>% 
    map_dfr(tidy, .id = "predictor") %>% 
    ggplot(aes(x = fct_reorder(predictor, estimate))) + 
    geom_crossbar(aes(y = estimate, ymin = conf.low, ymax = conf.high)) +
    labs(x = NULL, y = "Correlation with mpg")

1.5

Back to top