使用这个数据
我希望缩放的对象是最后五个网站(
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
)。
请问有什么建议可以让缩放对象变为最后五个网站吗?