R 反转主y轴并还原次轴

R 反转主y轴并还原次轴,r,ggplot2,R,Ggplot2,我有以下两个图表: #Rainfall ggplot(d, aes(x = Date, y = Rainfall, rm.na=TRUE)) + geom_col(size = 1, fill = "darkblue") + theme(axis.text.x=element_text(angle=60, hjust=1, size=7)) + ylab("Rainfall (in)") + scale_x_date(date_labels = &qu

我有以下两个图表:

#Rainfall
ggplot(d, aes(x = Date, y = Rainfall, rm.na=TRUE)) +
  geom_col(size = 1, fill = "darkblue") + theme(axis.text.x=element_text(angle=60, hjust=1, size=7)) + ylab("Rainfall (in)") + scale_x_date(date_labels = "%B") +
 ggsave(paste0("~/Desktop/plots", ".png"), width = 30, height = 20, units = "cm") 

#A1 DTW
ggplot(d1, rm.na=TRUE) +
geom_line(aes(x = Date, y = DTW, color = WellID)) + scale_x_date(date_labels = "%B") + theme(axis.text.x=element_text(angle=60, hjust=1, size=7)) + ggtitle("Depth to Water Area 1") + scale_y_continuous(trans="reverse", name="DTW (ft BGS)", limits=c(20, 0)) + ggsave(paste0("~/Desktop/plots", ".png"), width = 30, height = 20, units = "cm") 
我试图将它们与主轴(DTW)反向组合,但次轴(降雨)恢复为正常方向。我使用下面的代码,但它不会使主代码反转或具有正确的限制

#A1 DTW + Rainfall
ggplot() +
geom_line(d1, rm.na=TRUE, mapping = aes(x = Date, y = DTW, color = WellID)) + scale_x_date(date_labels = "%B") + theme(axis.text.x=element_text(angle=60, hjust=1, size=7)) + ggtitle("Depth to Water Area 1") + scale_y_continuous(trans="reverse", name="DTW (ft BGS)", limits=c(20, 0)) +
  geom_col(d, mapping = aes(x = Date, y = Rainfall, rm.na=TRUE), size = 1, fill = "darkblue") + theme(axis.text.x=element_text(angle=60, hjust=1, size=7)) + scale_y_continuous(sec.axis = sec_axis(~.*1, name = "Rainfall (in)")) + ggsave(paste0("~/Desktop/plots", ".png"), width = 30, height = 20, units = "cm") 
有什么帮助吗