- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
问题:
我想将 geom_hline
中的 geom_segment
添加到 3 个 stat_summary
点中的每一个,以确定每个物种的平均值。
当前代码:
library(tidyverse)
library(scales)
library(showtext)
font_add_google("Tomorrow", "Tomorrow")
font_add_google("Tomorrow", "Tomorrow")
showtext_auto()
theme_set(theme_light(base_size = 24, base_family = "Tomorrow"))
cbbPalette <- c("#27a8f7", "#88c0d0", "#B9C8D7")
set.seed(2020)
body_mass_avg <- penguins %>%
summarize(body_mass_avg = mean(body_mass_g, na.rm = TRUE)) %>%
pull(body_mass_avg)
penguins %>%
na.omit() %>%
group_by(species, island, sex) %>%
ggplot(aes(x=reorder(species, -body_mass_g), y = body_mass_g, color = species))+
geom_jitter(position = position_jitter(seed = 2020, width = 0.2), alpha = 0.25, size = 2)+
stat_summary(fun = mean, geom = "point", size = 5, alpha = 1)+
geom_hline(aes(yintercept = body_mass_avg), color = "gray70", size = 0.6)+
coord_flip() +
scale_color_manual(values=cbbPalette)+
scale_y_continuous(labels = scales::comma)+
labs(x = NULL, y = "Body Mass (g)")+
theme(legend.position = "NONE",
axis.title = element_text(family = "Tomorrow", size = 13),
axis.text.y = element_text(family = "Tomorrow", size = 15),
axis.text.x = element_text(family = "Tomorrow", size = 15),
panel.grid = element_blank())
数据:
penguins <- structure(list(species = structure(c(3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L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, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L), .Label = c("Gentoo", "Chinstrap", "Adelie"), class = "factor"),
island = c("Torgersen", "Torgersen", "Torgersen", "Torgersen",
"Torgersen", "Torgersen", "Torgersen", "Torgersen", "Torgersen",
"Torgersen", "Torgersen", "Torgersen", "Torgersen", "Torgersen",
"Torgersen", "Torgersen", "Torgersen", "Torgersen", "Torgersen",
"Torgersen", "Biscoe", "Biscoe", "Biscoe", "Biscoe", "Biscoe",
"Biscoe", "Biscoe", "Biscoe", "Biscoe", "Biscoe", "Dream",
"Dream", "Dream", "Dream", "Dream", "Dream", "Dream", "Dream",
"Dream", "Dream", "Dream", "Dream", "Dream", "Dream", "Dream",
"Dream", "Dream", "Dream", "Dream", "Dream", "Biscoe", "Biscoe",
"Biscoe", "Biscoe", "Biscoe", "Biscoe", "Biscoe", "Biscoe",
"Biscoe", "Biscoe", "Biscoe", "Biscoe", "Biscoe", "Biscoe",
"Biscoe", "Biscoe", "Biscoe", "Biscoe", "Torgersen", "Torgersen",
"Torgersen", "Torgersen", "Torgersen", "Torgersen", "Torgersen",
"Torgersen", "Torgersen", "Torgersen", "Torgersen", "Torgersen",
"Torgersen", "Torgersen", "Torgersen", "Torgersen", "Dream",
"Dream", "Dream", "Dream", "Dream", "Dream", "Dream", "Dream",
"Dream", "Dream", "Dream", "Dream", "Dream", "Dream", "Dream",
"Dream", "Biscoe", "Biscoe", "Biscoe", "Biscoe", "Biscoe",
"Biscoe", "Biscoe", "Biscoe", "Biscoe", "Biscoe", "Biscoe",
"Biscoe", "Biscoe", "Biscoe", "Biscoe", "Biscoe", "Torgersen",
"Torgersen", "Torgersen", "Torgersen", "Torgersen", "Torgersen",
"Torgersen", "Torgersen", "Torgersen", "Torgersen", "Torgersen",
"Torgersen", "Torgersen", "Torgersen", "Torgersen", "Torgersen",
"Dream", "Dream", "Dream", "Dream", "Dream", "Dream", "Dream",
"Dream", "Dream", "Dream", "Dream", "Dream", "Dream", "Dream",
"Dream", "Dream", "Dream", "Dream", "Dream", "Dream", "Biscoe",
"Biscoe", "Biscoe", "Biscoe", "Biscoe", "Biscoe", "Biscoe",
"Biscoe", "Biscoe", "Biscoe", "Biscoe", "Biscoe", "Biscoe",
"Biscoe", "Biscoe", "Biscoe", "Biscoe", "Biscoe", "Biscoe",
"Biscoe", "Biscoe", "Biscoe", "Biscoe", "Biscoe", "Biscoe",
"Biscoe", "Biscoe", "Biscoe", "Biscoe", "Biscoe", "Biscoe",
"Biscoe", "Biscoe", "Biscoe", "Biscoe", "Biscoe", "Biscoe",
"Biscoe", "Biscoe", "Biscoe", "Biscoe", "Biscoe", "Biscoe",
"Biscoe", "Biscoe", "Biscoe", "Biscoe", "Biscoe", "Biscoe",
"Biscoe", "Biscoe", "Biscoe", "Biscoe", "Biscoe", "Biscoe",
"Biscoe", "Biscoe", "Biscoe", "Biscoe", "Biscoe", "Biscoe",
"Biscoe", "Biscoe", "Biscoe", "Biscoe", "Biscoe", "Biscoe",
"Biscoe", "Biscoe", "Biscoe", "Biscoe", "Biscoe", "Biscoe",
"Biscoe", "Biscoe", "Biscoe", "Biscoe", "Biscoe", "Biscoe",
"Biscoe", "Biscoe", "Biscoe", "Biscoe", "Biscoe", "Biscoe",
"Biscoe", "Biscoe", "Biscoe", "Biscoe", "Biscoe", "Biscoe",
"Biscoe", "Biscoe", "Biscoe", "Biscoe", "Biscoe", "Biscoe",
"Biscoe", "Biscoe", "Biscoe", "Biscoe", "Biscoe", "Biscoe",
"Biscoe", "Biscoe", "Biscoe", "Biscoe", "Biscoe", "Biscoe",
"Biscoe", "Biscoe", "Biscoe", "Biscoe", "Biscoe", "Biscoe",
"Biscoe", "Biscoe", "Biscoe", "Biscoe", "Biscoe", "Biscoe",
"Biscoe", "Biscoe", "Biscoe", "Dream", "Dream", "Dream",
"Dream", "Dream", "Dream", "Dream", "Dream", "Dream", "Dream",
"Dream", "Dream", "Dream", "Dream", "Dream", "Dream", "Dream",
"Dream", "Dream", "Dream", "Dream", "Dream", "Dream", "Dream",
"Dream", "Dream", "Dream", "Dream", "Dream", "Dream", "Dream",
"Dream", "Dream", "Dream", "Dream", "Dream", "Dream", "Dream",
"Dream", "Dream", "Dream", "Dream", "Dream", "Dream", "Dream",
"Dream", "Dream", "Dream", "Dream", "Dream", "Dream", "Dream",
"Dream", "Dream", "Dream", "Dream", "Dream", "Dream", "Dream",
"Dream", "Dream", "Dream", "Dream", "Dream", "Dream", "Dream",
"Dream", "Dream"), bill_length_mm = c(39.1, 39.5, 40.3, NA,
36.7, 39.3, 38.9, 39.2, 34.1, 42, 37.8, 37.8, 41.1, 38.6,
34.6, 36.6, 38.7, 42.5, 34.4, 46, 37.8, 37.7, 35.9, 38.2,
38.8, 35.3, 40.6, 40.5, 37.9, 40.5, 39.5, 37.2, 39.5, 40.9,
36.4, 39.2, 38.8, 42.2, 37.6, 39.8, 36.5, 40.8, 36, 44.1,
37, 39.6, 41.1, 37.5, 36, 42.3, 39.6, 40.1, 35, 42, 34.5,
41.4, 39, 40.6, 36.5, 37.6, 35.7, 41.3, 37.6, 41.1, 36.4,
41.6, 35.5, 41.1, 35.9, 41.8, 33.5, 39.7, 39.6, 45.8, 35.5,
42.8, 40.9, 37.2, 36.2, 42.1, 34.6, 42.9, 36.7, 35.1, 37.3,
41.3, 36.3, 36.9, 38.3, 38.9, 35.7, 41.1, 34, 39.6, 36.2,
40.8, 38.1, 40.3, 33.1, 43.2, 35, 41, 37.7, 37.8, 37.9, 39.7,
38.6, 38.2, 38.1, 43.2, 38.1, 45.6, 39.7, 42.2, 39.6, 42.7,
38.6, 37.3, 35.7, 41.1, 36.2, 37.7, 40.2, 41.4, 35.2, 40.6,
38.8, 41.5, 39, 44.1, 38.5, 43.1, 36.8, 37.5, 38.1, 41.1,
35.6, 40.2, 37, 39.7, 40.2, 40.6, 32.1, 40.7, 37.3, 39, 39.2,
36.6, 36, 37.8, 36, 41.5, 46.1, 50, 48.7, 50, 47.6, 46.5,
45.4, 46.7, 43.3, 46.8, 40.9, 49, 45.5, 48.4, 45.8, 49.3,
42, 49.2, 46.2, 48.7, 50.2, 45.1, 46.5, 46.3, 42.9, 46.1,
44.5, 47.8, 48.2, 50, 47.3, 42.8, 45.1, 59.6, 49.1, 48.4,
42.6, 44.4, 44, 48.7, 42.7, 49.6, 45.3, 49.6, 50.5, 43.6,
45.5, 50.5, 44.9, 45.2, 46.6, 48.5, 45.1, 50.1, 46.5, 45,
43.8, 45.5, 43.2, 50.4, 45.3, 46.2, 45.7, 54.3, 45.8, 49.8,
46.2, 49.5, 43.5, 50.7, 47.7, 46.4, 48.2, 46.5, 46.4, 48.6,
47.5, 51.1, 45.2, 45.2, 49.1, 52.5, 47.4, 50, 44.9, 50.8,
43.4, 51.3, 47.5, 52.1, 47.5, 52.2, 45.5, 49.5, 44.5, 50.8,
49.4, 46.9, 48.4, 51.1, 48.5, 55.9, 47.2, 49.1, 47.3, 46.8,
41.7, 53.4, 43.3, 48.1, 50.5, 49.8, 43.5, 51.5, 46.2, 55.1,
44.5, 48.8, 47.2, NA, 46.8, 50.4, 45.2, 49.9, 46.5, 50, 51.3,
45.4, 52.7, 45.2, 46.1, 51.3, 46, 51.3, 46.6, 51.7, 47, 52,
45.9, 50.5, 50.3, 58, 46.4, 49.2, 42.4, 48.5, 43.2, 50.6,
46.7, 52, 50.5, 49.5, 46.4, 52.8, 40.9, 54.2, 42.5, 51, 49.7,
47.5, 47.6, 52, 46.9, 53.5, 49, 46.2, 50.9, 45.5, 50.9, 50.8,
50.1, 49, 51.5, 49.8, 48.1, 51.4, 45.7, 50.7, 42.5, 52.2,
45.2, 49.3, 50.2, 45.6, 51.9, 46.8, 45.7, 55.8, 43.5, 49.6,
50.8, 50.2), bill_depth_mm = c(18.7, 17.4, 18, NA, 19.3,
20.6, 17.8, 19.6, 18.1, 20.2, 17.1, 17.3, 17.6, 21.2, 21.1,
17.8, 19, 20.7, 18.4, 21.5, 18.3, 18.7, 19.2, 18.1, 17.2,
18.9, 18.6, 17.9, 18.6, 18.9, 16.7, 18.1, 17.8, 18.9, 17,
21.1, 20, 18.5, 19.3, 19.1, 18, 18.4, 18.5, 19.7, 16.9, 18.8,
19, 18.9, 17.9, 21.2, 17.7, 18.9, 17.9, 19.5, 18.1, 18.6,
17.5, 18.8, 16.6, 19.1, 16.9, 21.1, 17, 18.2, 17.1, 18, 16.2,
19.1, 16.6, 19.4, 19, 18.4, 17.2, 18.9, 17.5, 18.5, 16.8,
19.4, 16.1, 19.1, 17.2, 17.6, 18.8, 19.4, 17.8, 20.3, 19.5,
18.6, 19.2, 18.8, 18, 18.1, 17.1, 18.1, 17.3, 18.9, 18.6,
18.5, 16.1, 18.5, 17.9, 20, 16, 20, 18.6, 18.9, 17.2, 20,
17, 19, 16.5, 20.3, 17.7, 19.5, 20.7, 18.3, 17, 20.5, 17,
18.6, 17.2, 19.8, 17, 18.5, 15.9, 19, 17.6, 18.3, 17.1, 18,
17.9, 19.2, 18.5, 18.5, 17.6, 17.5, 17.5, 20.1, 16.5, 17.9,
17.1, 17.2, 15.5, 17, 16.8, 18.7, 18.6, 18.4, 17.8, 18.1,
17.1, 18.5, 13.2, 16.3, 14.1, 15.2, 14.5, 13.5, 14.6, 15.3,
13.4, 15.4, 13.7, 16.1, 13.7, 14.6, 14.6, 15.7, 13.5, 15.2,
14.5, 15.1, 14.3, 14.5, 14.5, 15.8, 13.1, 15.1, 14.3, 15,
14.3, 15.3, 15.3, 14.2, 14.5, 17, 14.8, 16.3, 13.7, 17.3,
13.6, 15.7, 13.7, 16, 13.7, 15, 15.9, 13.9, 13.9, 15.9, 13.3,
15.8, 14.2, 14.1, 14.4, 15, 14.4, 15.4, 13.9, 15, 14.5, 15.3,
13.8, 14.9, 13.9, 15.7, 14.2, 16.8, 14.4, 16.2, 14.2, 15,
15, 15.6, 15.6, 14.8, 15, 16, 14.2, 16.3, 13.8, 16.4, 14.5,
15.6, 14.6, 15.9, 13.8, 17.3, 14.4, 14.2, 14, 17, 15, 17.1,
14.5, 16.1, 14.7, 15.7, 15.8, 14.6, 14.4, 16.5, 15, 17, 15.5,
15, 13.8, 16.1, 14.7, 15.8, 14, 15.1, 15.2, 15.9, 15.2, 16.3,
14.1, 16, 15.7, 16.2, 13.7, NA, 14.3, 15.7, 14.8, 16.1, 17.9,
19.5, 19.2, 18.7, 19.8, 17.8, 18.2, 18.2, 18.9, 19.9, 17.8,
20.3, 17.3, 18.1, 17.1, 19.6, 20, 17.8, 18.6, 18.2, 17.3,
17.5, 16.6, 19.4, 17.9, 19, 18.4, 19, 17.8, 20, 16.6, 20.8,
16.7, 18.8, 18.6, 16.8, 18.3, 20.7, 16.6, 19.9, 19.5, 17.5,
19.1, 17, 17.9, 18.5, 17.9, 19.6, 18.7, 17.3, 16.4, 19, 17.3,
19.7, 17.3, 18.8, 16.6, 19.9, 18.8, 19.4, 19.5, 16.5, 17,
19.8, 18.1, 18.2, 19, 18.7), flipper_length_mm = c(181, 186,
195, NA, 193, 190, 181, 195, 193, 190, 186, 180, 182, 191,
198, 185, 195, 197, 184, 194, 174, 180, 189, 185, 180, 187,
183, 187, 172, 180, 178, 178, 188, 184, 195, 196, 190, 180,
181, 184, 182, 195, 186, 196, 185, 190, 182, 179, 190, 191,
186, 188, 190, 200, 187, 191, 186, 193, 181, 194, 185, 195,
185, 192, 184, 192, 195, 188, 190, 198, 190, 190, 196, 197,
190, 195, 191, 184, 187, 195, 189, 196, 187, 193, 191, 194,
190, 189, 189, 190, 202, 205, 185, 186, 187, 208, 190, 196,
178, 192, 192, 203, 183, 190, 193, 184, 199, 190, 181, 197,
198, 191, 193, 197, 191, 196, 188, 199, 189, 189, 187, 198,
176, 202, 186, 199, 191, 195, 191, 210, 190, 197, 193, 199,
187, 190, 191, 200, 185, 193, 193, 187, 188, 190, 192, 185,
190, 184, 195, 193, 187, 201, 211, 230, 210, 218, 215, 210,
211, 219, 209, 215, 214, 216, 214, 213, 210, 217, 210, 221,
209, 222, 218, 215, 213, 215, 215, 215, 216, 215, 210, 220,
222, 209, 207, 230, 220, 220, 213, 219, 208, 208, 208, 225,
210, 216, 222, 217, 210, 225, 213, 215, 210, 220, 210, 225,
217, 220, 208, 220, 208, 224, 208, 221, 214, 231, 219, 230,
214, 229, 220, 223, 216, 221, 221, 217, 216, 230, 209, 220,
215, 223, 212, 221, 212, 224, 212, 228, 218, 218, 212, 230,
218, 228, 212, 224, 214, 226, 216, 222, 203, 225, 219, 228,
215, 228, 216, 215, 210, 219, 208, 209, 216, 229, 213, 230,
217, 230, 217, 222, 214, NA, 215, 222, 212, 213, 192, 196,
193, 188, 197, 198, 178, 197, 195, 198, 193, 194, 185, 201,
190, 201, 197, 181, 190, 195, 181, 191, 187, 193, 195, 197,
200, 200, 191, 205, 187, 201, 187, 203, 195, 199, 195, 210,
192, 205, 210, 187, 196, 196, 196, 201, 190, 212, 187, 198,
199, 201, 193, 203, 187, 197, 191, 203, 202, 194, 206, 189,
195, 207, 202, 193, 210, 198), body_mass_g = c(3750, 3800,
3250, NA, 3450, 3650, 3625, 4675, 3475, 4250, 3300, 3700,
3200, 3800, 4400, 3700, 3450, 4500, 3325, 4200, 3400, 3600,
3800, 3950, 3800, 3800, 3550, 3200, 3150, 3950, 3250, 3900,
3300, 3900, 3325, 4150, 3950, 3550, 3300, 4650, 3150, 3900,
3100, 4400, 3000, 4600, 3425, 2975, 3450, 4150, 3500, 4300,
3450, 4050, 2900, 3700, 3550, 3800, 2850, 3750, 3150, 4400,
3600, 4050, 2850, 3950, 3350, 4100, 3050, 4450, 3600, 3900,
3550, 4150, 3700, 4250, 3700, 3900, 3550, 4000, 3200, 4700,
3800, 4200, 3350, 3550, 3800, 3500, 3950, 3600, 3550, 4300,
3400, 4450, 3300, 4300, 3700, 4350, 2900, 4100, 3725, 4725,
3075, 4250, 2925, 3550, 3750, 3900, 3175, 4775, 3825, 4600,
3200, 4275, 3900, 4075, 2900, 3775, 3350, 3325, 3150, 3500,
3450, 3875, 3050, 4000, 3275, 4300, 3050, 4000, 3325, 3500,
3500, 4475, 3425, 3900, 3175, 3975, 3400, 4250, 3400, 3475,
3050, 3725, 3000, 3650, 4250, 3475, 3450, 3750, 3700, 4000,
4500, 5700, 4450, 5700, 5400, 4550, 4800, 5200, 4400, 5150,
4650, 5550, 4650, 5850, 4200, 5850, 4150, 6300, 4800, 5350,
5700, 5000, 4400, 5050, 5000, 5100, 4100, 5650, 4600, 5550,
5250, 4700, 5050, 6050, 5150, 5400, 4950, 5250, 4350, 5350,
3950, 5700, 4300, 4750, 5550, 4900, 4200, 5400, 5100, 5300,
4850, 5300, 4400, 5000, 4900, 5050, 4300, 5000, 4450, 5550,
4200, 5300, 4400, 5650, 4700, 5700, 4650, 5800, 4700, 5550,
4750, 5000, 5100, 5200, 4700, 5800, 4600, 6000, 4750, 5950,
4625, 5450, 4725, 5350, 4750, 5600, 4600, 5300, 4875, 5550,
4950, 5400, 4750, 5650, 4850, 5200, 4925, 4875, 4625, 5250,
4850, 5600, 4975, 5500, 4725, 5500, 4700, 5500, 4575, 5500,
5000, 5950, 4650, 5500, 4375, 5850, 4875, 6000, 4925, NA,
4850, 5750, 5200, 5400, 3500, 3900, 3650, 3525, 3725, 3950,
3250, 3750, 4150, 3700, 3800, 3775, 3700, 4050, 3575, 4050,
3300, 3700, 3450, 4400, 3600, 3400, 2900, 3800, 3300, 4150,
3400, 3800, 3700, 4550, 3200, 4300, 3350, 4100, 3600, 3900,
3850, 4800, 2700, 4500, 3950, 3650, 3550, 3500, 3675, 4450,
3400, 4300, 3250, 3675, 3325, 3950, 3600, 4050, 3350, 3450,
3250, 4050, 3800, 3525, 3950, 3650, 3650, 4000, 3400, 3775,
4100, 3775), sex = structure(c(2L, 1L, 1L, NA, 1L, 2L, 1L,
2L, NA, NA, NA, NA, 1L, 2L, 2L, 1L, 1L, 2L, 1L, 2L, 1L, 2L,
1L, 2L, 2L, 1L, 2L, 1L, 1L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1L, 2L, 1L, 2L, 1L, 2L,
2L, 1L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L,
2L, 1L, 2L, 2L, 1L, 1L, 2L, 1L, 2L, 2L, 1L, 2L, 1L, 1L, 2L,
1L, 2L, 2L, 1L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 2L, 1L, 2L,
1L, 1L, 2L, 1L, 2L, 2L, 1L), .Label = c("female", "male"), class = "factor"),
year = c(2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007,
2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007,
2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007,
2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007,
2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007,
2007, 2007, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008,
2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008,
2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008,
2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008,
2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008,
2008, 2008, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009,
2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009,
2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009,
2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009,
2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009,
2009, 2009, 2009, 2009, 2007, 2007, 2007, 2007, 2007, 2007,
2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007,
2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007,
2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2008, 2008,
2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008,
2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008,
2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008,
2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008,
2008, 2008, 2008, 2008, 2009, 2009, 2009, 2009, 2009, 2009,
2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009,
2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009,
2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009,
2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2007, 2007,
2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007,
2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007,
2007, 2007, 2007, 2007, 2008, 2008, 2008, 2008, 2008, 2008,
2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008,
2008, 2008, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009,
2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009, 2009,
2009, 2009, 2009, 2009, 2009, 2009)), row.names = c(NA, -344L
), spec = structure(list(cols = list(species = structure(list(), class = c("collector_character",
"collector")), island = structure(list(), class = c("collector_character",
"collector")), bill_length_mm = structure(list(), class = c("collector_double",
"collector")), bill_depth_mm = structure(list(), class = c("collector_double",
"collector")), flipper_length_mm = structure(list(), class = c("collector_double",
"collector")), body_mass_g = structure(list(), class = c("collector_double",
"collector")), sex = structure(list(), class = c("collector_character",
"collector")), year = structure(list(), class = c("collector_double",
"collector"))), default = structure(list(), class = c("collector_guess",
"collector")), skip = 1), class = "col_spec"), class = c("spec_tbl_df",
"tbl_df", "tbl", "data.frame"))
最佳答案
您可以通过转换 geom_segment
中的数据来调用 geom_segment
来完成此操作:
theme_set(theme_light(base_size = 24))
cbbPalette <- c("#27a8f7", "#88c0d0", "#B9C8D7")
set.seed(2019)
body_mass_avg = mean(penguins$body_mass_g, na.rm=TRUE)
penguins %>%
na.omit() %>%
group_by(species, island) %>%
mutate(m = mean(body_mass_g)) %>%
arrange(-m) %>%
ungroup %>%
mutate(species=factor(species, levels=unique(species))) %>%
ggplot(aes(x=species, y = body_mass_g, color = species))+
geom_jitter(position = position_jitter(seed = 2020, width = 0.2, height=0),
alpha = 0.25, size = 2)+
stat_summary(fun = mean, geom = "point", size = 4, alpha = 1)+
geom_hline(aes(yintercept = body_mass_avg), color = "gray70", size = 0.6) +
geom_segment(data=. %>%
group_by(species, island) %>%
summarise(body_mass_g=mean(body_mass_g)) %>%
mutate(body_mass_avg=body_mass_avg),
aes(y=body_mass_avg, yend=body_mass_g, xend=species), size=1) +
coord_flip() +
scale_color_manual(values=cbbPalette) +
scale_y_continuous(labels = scales::comma)+
labs(x = NULL, y = "Body Mass (g)")
关于r - 使用 geom_segment 连接 geom_hline,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63123515/
我知道这个问题可能已经被问过,但我检查了所有这些,我认为我的情况有所不同(请友善)。所以我有两个数据集,第一个是测试数据集,第二个是我保存在数据框中的预测(预测值,这就是没有数据列的原因)。我想合并两
在 .loc 方法的帮助下,我根据同一数据框中另一列中的值来识别 Panda 数据框中某一列中的值。 下面给出了代码片段供您引用: var1 = output_df['Player'].loc[out
当我在 Windows 中使用 WinSCP 通过 Ubuntu 连接到 VMware 时,它提示: The server rejected SFTP connection, but it lis
我正在开发一个使用 xml web 服务的 android 应用程序。在 wi-fi 网络中连接时工作正常,但在 3G 网络中连接时失败(未找到 http 404)。 这不仅仅发生在设备中。为了进行测
我有一个XIB包含我的控件的文件,加载到 Interface Builder(Snow Leopard 上的 Xcode 4.0.2)中。 文件的所有者被设置为 someClassController
我在本地计算机上管理 MySQL 数据库,并通过运行以下程序通过 C 连接到它: #include #include #include int main(int argc, char** arg
我不知道为什么每次有人访问我网站上的页面时,都会打开一个与数据库的新连接。最终我到达了大约 300 并收到错误并且页面不再加载。我认为它应该工作的方式是,我将 maxIdle 设置为 30,这意味着
希望清理 NMEA GPS 中的 .txt 文件。我当前的代码如下。 deletes = ['$GPGGA', '$GPGSA', '$GPGSV', '$PSRF156', ] searchquer
我有一个 URL、一个用户名和一个密码。我想在 C# .Net WinForms 中建立 VPN 连接。 你能告诉我从哪里开始吗?任何第三方 API? 代码示例将受到高度赞赏... 最佳答案 您可以像
有没有更好的方法将字符串 vector 转换为字符 vector ,字符串之间的终止符为零。 因此,如果我有一个包含以下字符串的 vector "test","my","string",那么我想接收一
我正在编写一个库,它不断检查 android 设备的连接,并在设备连接、断开连接或互联网连接变慢时给出回调。 https://github.com/muddassir235/connection_ch
我的操作系统:Centos 7 + CLOUDLINUX 7.7当我尝试从服务器登录Mysql时 [root@server3 ~]# Mysql -u root -h localhost -P 330
我收到错误:Puma 发现此错误:无法打开到本地主机的 TCP 连接:9200(连接被拒绝 - 连接(2)用于“本地主机”端口 9200)(Faraday::ConnectionFailed)在我的
请给我一些解决以下错误的方法。 这是一个聊天应用....代码和错误如下:: conversations_controller.rb def create if Conversation.bet
我想将两个单元格中的数据连接到一个单元格中。我还想只组合那些具有相同 ID 的单元格。 任务 ID 名称 4355.2 参与者 4355.2 领袖 4462.1 在线 4462.1 快速 4597.1
我经常需要连接 TSQL 中的字段... 使用“+”运算符时 TSQL 强制您处理的两个问题是 Data Type Precedence和 NULL 值。 使用数据类型优先级,问题是转换错误。 1)
有没有在 iPad 或 iPhone 应用程序中使用 Facebook 连接。 这个想法是登录这个应用程序,然后能够看到我的哪些 facebook 用户也在使用该应用程序及其功能。 最佳答案 是的。
我在连接或打印字符串时遇到了一个奇怪的问题。我有一个 char * ,可以将其设置为字符串文字的几个值之一。 char *myStrLiteral = NULL; ... if(blah) myS
对于以下数据 - let $x := "Yahooooo !!!! Select one number - " let $y := 1 2 3 4 5 6 7 我想得到
我正在看 UDEMY for perl 的培训视频,但是视频不清晰,看起来有错误。 培训展示了如何使用以下示例连接 2 个字符串: #!usr/bin/perl print $str = "Hi";
我是一名优秀的程序员,十分优秀!