【发布时间】:2020-12-04 05:24:01
【问题描述】:
我希望 Y 轴左侧有一个指向该轴的箭头,以及箭头旁边的文本。
到目前为止,这是我的代码:
co2_diff_2050 %>%
ggplot( aes( Year, MTC, fill = Sector ) ) +
geom_bar( position = "stack", stat = "identity" ) +
scale_fill_manual( values = CO2_sector_color ) +
scale_x_continuous( name = "Year", breaks = c( 2050 ) ) +
scale_y_continuous( name = "MTC", breaks = c( 0, 5, 10 ), limits = c( -1, 13 ) ) +
geom_segment(aes(x = 2049.5, y = maryland_80goal, xend = 2049.8, yend = maryland_80goal),
arrow = arrow(length = unit(0.5, "cm"))) +
geom_errorbar( aes( ymin = net_diff, ymax = net_diff ), color = "gray30", linetype = "longdash", width = 1, size = 1 ) +
geom_hline( yintercept = 0 ) +
theme_bw() +
guides( fill = guide_legend( ncol = 1 ) ) +
theme( legend.position = "right" ) +
labs( title = "Maryland Remaining CO2 Emissions by Sector in 2050",
caption = "Arrow indicates Maryland's 2050 GHG emissions reduction goal
Dashed gray line indicates emissions with biomass offset") +
facet_wrap( ~ Scenario, nrow = 1 )
【问题讨论】:
-
您的意思是箭头应该位于绘图的外部/左侧并指向 y 轴?
-
@zoowalk 正确!我将添加一张我的目标的图片