ggplot2: Reversing secondary continuous x axis

淺唱寂寞╮ 提交于 2019-11-29 12:28:37

Here is a possibile solution:

MasterTable <- data.frame(Concentration=rep(c(0,50,100,200,300, 350, 400),2),
Signal=c(11800,13000,12000,12000,16000,15500,15570,11600,11700,8000,8000,6000,4000,3000),
Assay=rep(1:2,each=7))

library(ggplot2)
# Reverse Signal vector of the blue series (for Assay =1)
MasterTable$Signal[MasterTable$Assay==1] <- rev(MasterTable$Signal[MasterTable$Assay==1])

ggplot(data=MasterTable, aes(x=Concentration, y=Signal, color=factor(Assay))) + 
geom_line(lwd=1) + geom_point(size=3) + guides(color='none') +
scale_x_continuous('Chemical 1 (nM)', trans='reverse',
                   sec.axis = sec_axis(~ 400 - . , name='Chemical 2 (nM)')) 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!