Annual exceedance probability scale in ggplot





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I've got a dataframe df of calculated Annual exceedance probability (AEP) of daily maximum liquid precipitation (P):



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
)


All I need is to create a specific scale with equal distance between breaks in the middle and increasing on both ends. A perfect example from book is here:



enter image description here



All I was able to create by myself (based on code chuncks from this gist) return me a mess of labels:



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)


enter image description here










share|improve this question























  • How exactly do you want to determine the breaks? Is taking all the AEP values from your data what you want, or just the first try at it?

    – camille
    Nov 16 '18 at 16:09











  • @camille I want all AEP values to be breaks or at least as on the example (e.g. without 0.001)

    – atsyplenkov
    Nov 16 '18 at 16:12











  • I'm not familiar with the context of this type of data or chart. Can you explain how the breaks in your chart differ from those in the example? Where do the example's breaks come from?

    – camille
    Nov 16 '18 at 16:37











  • @camille the distance between breaks should not be the same. On both ends where the probability is below 20 (or higher than 80) it is logscale. I know that in Python it's possible to do with 'probscale', for example (matplotlib.org/mpl-probscale)

    – atsyplenkov
    Nov 17 '18 at 7:27




















0















I've got a dataframe df of calculated Annual exceedance probability (AEP) of daily maximum liquid precipitation (P):



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
)


All I need is to create a specific scale with equal distance between breaks in the middle and increasing on both ends. A perfect example from book is here:



enter image description here



All I was able to create by myself (based on code chuncks from this gist) return me a mess of labels:



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)


enter image description here










share|improve this question























  • How exactly do you want to determine the breaks? Is taking all the AEP values from your data what you want, or just the first try at it?

    – camille
    Nov 16 '18 at 16:09











  • @camille I want all AEP values to be breaks or at least as on the example (e.g. without 0.001)

    – atsyplenkov
    Nov 16 '18 at 16:12











  • I'm not familiar with the context of this type of data or chart. Can you explain how the breaks in your chart differ from those in the example? Where do the example's breaks come from?

    – camille
    Nov 16 '18 at 16:37











  • @camille the distance between breaks should not be the same. On both ends where the probability is below 20 (or higher than 80) it is logscale. I know that in Python it's possible to do with 'probscale', for example (matplotlib.org/mpl-probscale)

    – atsyplenkov
    Nov 17 '18 at 7:27
















0












0








0








I've got a dataframe df of calculated Annual exceedance probability (AEP) of daily maximum liquid precipitation (P):



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
)


All I need is to create a specific scale with equal distance between breaks in the middle and increasing on both ends. A perfect example from book is here:



enter image description here



All I was able to create by myself (based on code chuncks from this gist) return me a mess of labels:



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)


enter image description here










share|improve this question














I've got a dataframe df of calculated Annual exceedance probability (AEP) of daily maximum liquid precipitation (P):



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
)


All I need is to create a specific scale with equal distance between breaks in the middle and increasing on both ends. A perfect example from book is here:



enter image description here



All I was able to create by myself (based on code chuncks from this gist) return me a mess of labels:



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)


enter image description here







r ggplot2 probability






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 16 '18 at 15:45









atsyplenkovatsyplenkov

305211




305211













  • How exactly do you want to determine the breaks? Is taking all the AEP values from your data what you want, or just the first try at it?

    – camille
    Nov 16 '18 at 16:09











  • @camille I want all AEP values to be breaks or at least as on the example (e.g. without 0.001)

    – atsyplenkov
    Nov 16 '18 at 16:12











  • I'm not familiar with the context of this type of data or chart. Can you explain how the breaks in your chart differ from those in the example? Where do the example's breaks come from?

    – camille
    Nov 16 '18 at 16:37











  • @camille the distance between breaks should not be the same. On both ends where the probability is below 20 (or higher than 80) it is logscale. I know that in Python it's possible to do with 'probscale', for example (matplotlib.org/mpl-probscale)

    – atsyplenkov
    Nov 17 '18 at 7:27





















  • How exactly do you want to determine the breaks? Is taking all the AEP values from your data what you want, or just the first try at it?

    – camille
    Nov 16 '18 at 16:09











  • @camille I want all AEP values to be breaks or at least as on the example (e.g. without 0.001)

    – atsyplenkov
    Nov 16 '18 at 16:12











  • I'm not familiar with the context of this type of data or chart. Can you explain how the breaks in your chart differ from those in the example? Where do the example's breaks come from?

    – camille
    Nov 16 '18 at 16:37











  • @camille the distance between breaks should not be the same. On both ends where the probability is below 20 (or higher than 80) it is logscale. I know that in Python it's possible to do with 'probscale', for example (matplotlib.org/mpl-probscale)

    – atsyplenkov
    Nov 17 '18 at 7:27



















How exactly do you want to determine the breaks? Is taking all the AEP values from your data what you want, or just the first try at it?

– camille
Nov 16 '18 at 16:09





How exactly do you want to determine the breaks? Is taking all the AEP values from your data what you want, or just the first try at it?

– camille
Nov 16 '18 at 16:09













@camille I want all AEP values to be breaks or at least as on the example (e.g. without 0.001)

– atsyplenkov
Nov 16 '18 at 16:12





@camille I want all AEP values to be breaks or at least as on the example (e.g. without 0.001)

– atsyplenkov
Nov 16 '18 at 16:12













I'm not familiar with the context of this type of data or chart. Can you explain how the breaks in your chart differ from those in the example? Where do the example's breaks come from?

– camille
Nov 16 '18 at 16:37





I'm not familiar with the context of this type of data or chart. Can you explain how the breaks in your chart differ from those in the example? Where do the example's breaks come from?

– camille
Nov 16 '18 at 16:37













@camille the distance between breaks should not be the same. On both ends where the probability is below 20 (or higher than 80) it is logscale. I know that in Python it's possible to do with 'probscale', for example (matplotlib.org/mpl-probscale)

– atsyplenkov
Nov 17 '18 at 7:27







@camille the distance between breaks should not be the same. On both ends where the probability is below 20 (or higher than 80) it is logscale. I know that in Python it's possible to do with 'probscale', for example (matplotlib.org/mpl-probscale)

– atsyplenkov
Nov 17 '18 at 7:27














1 Answer
1






active

oldest

votes


















0














I found an answer in one of the Stack Overflow's questions.
To create desired scale we need to apply a qnorm quantile function to all AEP values (or other x values), e.g.



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)


enter image description here






share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53341139%2fannual-exceedance-probability-scale-in-ggplot%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    I found an answer in one of the Stack Overflow's questions.
    To create desired scale we need to apply a qnorm quantile function to all AEP values (or other x values), e.g.



    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)


    enter image description here






    share|improve this answer




























      0














      I found an answer in one of the Stack Overflow's questions.
      To create desired scale we need to apply a qnorm quantile function to all AEP values (or other x values), e.g.



      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)


      enter image description here






      share|improve this answer


























        0












        0








        0







        I found an answer in one of the Stack Overflow's questions.
        To create desired scale we need to apply a qnorm quantile function to all AEP values (or other x values), e.g.



        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)


        enter image description here






        share|improve this answer













        I found an answer in one of the Stack Overflow's questions.
        To create desired scale we need to apply a qnorm quantile function to all AEP values (or other x values), e.g.



        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)


        enter image description here







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 17 '18 at 11:10









        atsyplenkovatsyplenkov

        305211




        305211
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53341139%2fannual-exceedance-probability-scale-in-ggplot%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Florida Star v. B. J. F.

            Danny Elfman

            The Sandy Post