我正在ggplot2中创建一个facet_wrap面板图。翻转x轴和y轴,以及x轴的反转。
示例数据集:
Position Depth Var Value
S07 1000 SFA 0.5885938
S07 1000 MFA 0.6228922
S07 1000 DFA 0.6276554
S07 120 SFA 0.7342712
S07 400 MFA 0.379946
S07 400 DFA 0.6565114
S07 120 SFA 0.7330876
S07 25 SFA 0.7505527
S07 120 DFA 0.461091
S07 25 SFA 0.6202075
S07 400 DFA 0.427386
S07 25 SFA 0.4705119
S08 200 SFA 0.6237663
S08 200 SFA 0.6275681
S08 400 MFA 0.4675334
S08 25 SFA 0.6647344
S08 1000 DFA 0.4452225
S08 200 SFA 0.3845796
S08 400 MFA 0.4521598
S08 400 SFA 0.5158677
S08 25 DFA 0.4556605
S08 25 SFA 0.5381858
S08 1000 DFA 0.434988
S08 1000 MFA 0.4554283
S09 200 SFA 0.6135895
S09 25 MFA 0.7472166
S09 400 SFA 0.4461884
S09 1000 DFA 0.4197083
... ... ... ...
我正在使用的代码,
library(ggplot2)
library(cowplot)
ggplot(df, aes(x=x, y=y, fill=Position))+
geom_point()+
geom_line(aes(group=Position)+
coord_flip() +
scale_x_reverse(breaks=c(25, 120,200, 400, 1000))+
scale_y_continuous(position = "top")+
facet_wrap(~var, nrow=2, scales='free')+
theme(strip.background = element_blank(),
panel.border = element_blank())
如何切换面板标题“SFA”和轴的位置,并连接两个轴,如右图所示?