R 如何在ggplot中反转轴顺序并使用预定义的比例?

R 如何在ggplot中反转轴顺序并使用预定义的比例?,r,ggplot2,R,Ggplot2,我读过一篇关于同时使用scale\u reverse和scale\u log10的提问。我有一个类似的问题,除了我想要“反转”的刻度是“刻度”包中预定义的刻度。这是我的密码: ##Defining y-breaks for probability scale ybreaks <- c(1,2,5,10,20,30,40,50,60,70,80,90,95,98,99)/100 #Random numbers, and their corresponding wei

我读过一篇关于同时使用
scale\u reverse
scale\u log10
的提问。我有一个类似的问题,除了我想要“反转”的刻度是“刻度”包中预定义的刻度。这是我的密码:

    ##Defining y-breaks for probability scale
    ybreaks <- c(1,2,5,10,20,30,40,50,60,70,80,90,95,98,99)/100

    #Random numbers, and their corresponding weibull probability valeus (which I'm trying to plot)
    x <- c(.3637, .1145, .8387, .9521, .330, .375, .139, .662, .824, .899)
    p <- c(.647, .941, .255, .059, .745, .549, .853, .451, .352, .157)
    df <- data.frame(x, p)

    require(scales)
    require(ggplot2)

    ggplot(df)+
        geom_point(aes(x=x, y=p, size=2))+
        stat_smooth(method="lm", se=FALSE, linetype="dashed", aes(x=x, y=p))+
        scale_x_continuous(trans='probit',
                           breaks=ybreaks,
                           minor_breaks=qnorm(ybreaks))+
        scale_y_log10()
##为概率标度定义y型断裂

ybreaks与其尝试组合两种转换,为什么不转换现有数据并绘制它呢? 下面的内容看起来应该是正确的

#http://r.789695.n4.nabble.com/Inverse-Error-Function-td802691.html
erf.inv <- function(x) qnorm((x + 1)/2)/sqrt(2)
#http://en.wikipedia.org/wiki/Probit#Computation 
probit <- function(x) sqrt(2)*erf.inv((2*x)-1) 
# probit(0.3637)
df$z <- probit(df$x)
ggplot(df)+
  geom_point(aes(x=z, y=p), size=2)+
  stat_smooth(method="lm", se=FALSE, linetype="dashed", aes(x=z, y=p))+
  scale_x_reverse(breaks = ybreaks,
                  minor_breaks=qnorm(ybreaks))+
  scale_y_log10()
#http://r.789695.n4.nabble.com/Inverse-Error-Function-td802691.html
scale(x | y)_reverse()
中的erf.inv参数被传递给
scale(x | y)_continuous()
,因此您只需执行以下操作:

scale_x_reverse(trans='probit', breaks = ybreaks, minor_breaks=qnorm(ybreaks))

这真的很有帮助。非常感谢。