如何解决减少facet_wrap中轴标签和轴之间的区域
我使用 facet_wrap
显示两个图,我想减少水平轴和轴上年份之间的距离,使年份更接近轴。有没有办法做到这一点?
ggplot( df,aes(x=year,y = value)) +
geom_area(aes(fill = variable)) +
facet_wrap(~ scenario,ncol=3) +
ylab("") +
xlab("") +
theme_bw() +
theme(
panel.border = element_blank(),panel.grid.major = element_blank(),panel.grid.minor = element_blank()) +
theme(axis.text.x = element_text(angle = 90)) +
theme(axis.title.y = element_text(angle = 0)) +
theme(axis.line = element_line(),strip.background = element_blank(),panel.margin = unit(2,"lines"))
这是数据集:
df <- structure(list(country = c("CAN","CAN","CAN"),year = c(2030,2030,2040,2040),scenario = structure(c(2L,2L,1L,1L),.Label = c("BAU","2Ci","2Cd"),class = "factor"),variable = structure(c(5L,5L,2L),.Label = c("ELEC","GAS","ROIL","OIL","COAL"),value = c(0.128654289458377,2.37568827939126,0.146615100987535,2.86487702956444,0.0980137869955521,1.62493493094997,0.150757647986727,2.74361420537482),unit = c("Exojoules","Exojoules","Exojoules"),sector = c("ECON","ECON","ECON")),row.names = c(NA,-8L),groups = structure(list(country = c("CAN",scenario = c("2Ci","BAU","BAU"),.rows = list(1:2,3:4,5:6,7:8)),-4L),class = c("tbl_df","tbl","data.frame")),class = c("grouped_df","tbl_df","data.frame"))
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。