ggplot 中的年度超标概率标度

Annual exceedance probability scale in ggplot

我有一个数据框 df 计算的每日最大液体降水量 (P) 的年度超标概率 (AEP):

df <- tibble::tribble(
   ~AEP,          ~P,
  0.001, 299.0973209,
   0.01, 254.7226534,
   0.03, 233.0298722,
   0.05, 223.9571177,
    0.1, 211.2898816,
    0.3, 190.5075232,
    0.5, 182.3294549,
      1, 170.5569051,
      3, 148.9113334,
      5,  138.991102,
     10, 125.4449161,
     20, 110.1408306,
     25,   104.74124,
     30, 100.2363357,
     40, 92.15268627,
     50, 85.75477796,
     60, 79.55311702,
     70, 73.44249835,
     75, 70.21061223,
     80, 66.79821521,
     90, 58.54507042,
     95, 52.44861458,
     97, 48.86357489,
     99, 43.12184627,
   99.5, 39.72675936,
   99.7,  37.5826596,
   99.9, 33.91759317
  )

我只需要创建一个特定的比例尺,中间的间隔距离相等,并且在 两端 两端增加。书中的一个完美示例在这里:

我能自己创造的一切(基于这个 gist 的代码块)return 我一堆乱七八糟的标签:

library(dplyr)
library(scales)
library(ggplot2)

df %>% 
  ggplot(aes(x = AEP, y = P)) + 
  geom_point() +
  geom_line() +
  scale_y_continuous(name = "Precipitation (P), mm",
                     labels = scales::comma,
                     breaks = seq(0, 300, 50)) +
  scale_x_continuous(name = "AEP, %",
                     breaks = df$AEP,
                     labels = str_c(df$AEP,'%'),
                     expand = c(0.001,0.001)) +
  theme_grey(base_size = 12)

我在 Stack Overflow 的 questions 中找到了答案。 要创建所需的比例,我们需要将 qnorm 分位数函数应用于所有 AEP 值(或其他 x 值),例如

df %>% 
  ggplot(aes(x = qnorm(AEP/100), # transform to quantiles
             y = P)) + 
  geom_point() +
  geom_line() +
  scale_y_continuous(name = "Precipitation (P), mm",
                     labels = scales::comma,
                     breaks = seq(0, 300, 50)) +
  scale_x_continuous(name = "AEP, %",
                     breaks = qnorm(df$AEP/100), #transform
                     labels = df$AEP,
                     expand = c(0.035,0.035)) +
  theme_bw(base_size = 12)