我已经创建了一个情节,ggplot
并使用ggtext
它来为我的字幕中的特定单词着色。虽然这样可行,但每次我渲染情节时,顶部都会出现过多的空白。下面是帮助呈现文本的代码,这是输出。关于我应该做什么的任何想法?
filter(threatened == 1,
!is.na(year_last_seen)) %>%
count(year_last_seen, threat_type) %>%
pivot_wider(names_from = year_last_seen, values_from = n) %>%
mutate_if(is.integer, as.numeric) %>%
mutate_all(~replace(., is.na(.), 0)) %>%
nest(c('1900-1919', '1920-1939', '1940-1959', '1960-1979', '1980-1999', '2000-2020')) %>%
mutate('2020_sum' = map_dbl(data, sum)) %>%
unnest() %>%
mutate(threat_type = fct_reorder(threat_type, `2020_sum`)) %>%
ggplot() +
geom_dumbbell(aes(y = threat_type, x = `Before 1900`, xend = `2020_sum`),
color='#E7E3D9', size = 1.5,
colour_x = '#1E5871', colour_xend = '#8F0700',
size_x = 4, size_xend = 4) +
# This is the text that is helping me colorize particular words in the subtitle.
labs(title = "Number of Plants Threated",
subtitle = "Change from <b style='color:#1E5871'>< 1900</b> through <b style='color:#8F0700'>2020</b>",
x = '',
y = '') +
theme(plot.subtitle = element_markdown())```