使用这个
数据
df <- read.table(text = c("
Site measured simulated
site1 9.1 6.8
site2 163.1 128.1
site3 126 75.9
site4 741.2 843
site5 2215.1 1937.7
site6 283.6 423.4
site7 115.6 92.5
site8 12.1 15.3
site9 13.4 15.8
site10 475.7 296.1
site11 1 1.4
site12 84.5 131.9
site13 74.1 43.9
site14 19.2 33.3
site15 74.8 41.1
site16 287.8 366.9"), header =T)
和下面的脚本
library(tidyr)
library(dplyr)
library(ggplot2)
library(ggforce)
df_reorder <- transform(df,
Site_reorder = reorder(Site, -measured))
df_long <- df_reorder %>% gather("id", "value", 2:3)
ggplot(df_long, aes(x = Site_reorder, y = value, fill = id))+
geom_bar(stat = "identity", position = "dodge", width = 0.7)+
scale_fill_manual(values=c("red", "black")) +
theme_bw()+
facet_zoom(x = Site_reorder%in%c("site14", "site9", "site8", "site1", "site11"))+
labs(x = "", y = " ")+
theme(legend.position = c(0.90, 0.90), legend.background = element_rect(fill="transparent"),
legend.title = element_blank(), axis.text.x=element_text(angle=55, vjust=1, hjust=1,size = 8))
我希望缩放用于最后五个站点(、site14
、site9
和site8
)。相反,它放大了前五个站点(、、、和)site1
site11
site5
site4
site10
site16
site6
任何关于如何为最后五个站点进行缩放的建议将不胜感激?