getting constant text size while using atop function in r











up vote
4
down vote

favorite












Below is a much simpler example of a complicated custom function I have written. In the full-length form of this function,





  • "layer1"corresponds to caption entered by the user,


  • "layer2"
    corresponds to results from a statistical test, and


  • "layer3"
    corresponds to details about the statistical test carried out.


But when all three layers are included in the caption, it looks something like this-





library(ggplot2)

ggplot(iris, aes(Species, Sepal.Length)) +
geom_boxplot() +
labs(caption = substitute(atop(substitute(
atop("layer1", "layer2")
)
, "layer3")))




Created on 2018-11-09 by the reprex package (v0.2.1)



So I wanted to figure out a way I can keep the text size constant for all three layers. I am actually not sure why the text size automatically changes in this context.



Is there a way I can prevent this from happening?










share|improve this question


























    up vote
    4
    down vote

    favorite












    Below is a much simpler example of a complicated custom function I have written. In the full-length form of this function,





    • "layer1"corresponds to caption entered by the user,


    • "layer2"
      corresponds to results from a statistical test, and


    • "layer3"
      corresponds to details about the statistical test carried out.


    But when all three layers are included in the caption, it looks something like this-





    library(ggplot2)

    ggplot(iris, aes(Species, Sepal.Length)) +
    geom_boxplot() +
    labs(caption = substitute(atop(substitute(
    atop("layer1", "layer2")
    )
    , "layer3")))




    Created on 2018-11-09 by the reprex package (v0.2.1)



    So I wanted to figure out a way I can keep the text size constant for all three layers. I am actually not sure why the text size automatically changes in this context.



    Is there a way I can prevent this from happening?










    share|improve this question
























      up vote
      4
      down vote

      favorite









      up vote
      4
      down vote

      favorite











      Below is a much simpler example of a complicated custom function I have written. In the full-length form of this function,





      • "layer1"corresponds to caption entered by the user,


      • "layer2"
        corresponds to results from a statistical test, and


      • "layer3"
        corresponds to details about the statistical test carried out.


      But when all three layers are included in the caption, it looks something like this-





      library(ggplot2)

      ggplot(iris, aes(Species, Sepal.Length)) +
      geom_boxplot() +
      labs(caption = substitute(atop(substitute(
      atop("layer1", "layer2")
      )
      , "layer3")))




      Created on 2018-11-09 by the reprex package (v0.2.1)



      So I wanted to figure out a way I can keep the text size constant for all three layers. I am actually not sure why the text size automatically changes in this context.



      Is there a way I can prevent this from happening?










      share|improve this question













      Below is a much simpler example of a complicated custom function I have written. In the full-length form of this function,





      • "layer1"corresponds to caption entered by the user,


      • "layer2"
        corresponds to results from a statistical test, and


      • "layer3"
        corresponds to details about the statistical test carried out.


      But when all three layers are included in the caption, it looks something like this-





      library(ggplot2)

      ggplot(iris, aes(Species, Sepal.Length)) +
      geom_boxplot() +
      labs(caption = substitute(atop(substitute(
      atop("layer1", "layer2")
      )
      , "layer3")))




      Created on 2018-11-09 by the reprex package (v0.2.1)



      So I wanted to figure out a way I can keep the text size constant for all three layers. I am actually not sure why the text size automatically changes in this context.



      Is there a way I can prevent this from happening?







      r ggplot2 tidyverse plotmath






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 10 at 2:59









      Indrajeet Patil

      1,335213




      1,335213
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          3
          down vote



          accepted










          I'm a little confused about the "substitute" in the plot, but perhaps the following solves the problem:



          ggplot(iris, aes(Species, Sepal.Length)) +
          geom_boxplot() +
          labs(caption = substitute(atop(
          atop(displaystyle("layer1"), displaystyle("layer2")), "layer3")))


          enter image description here






          share|improve this answer





















          • Cool. Wasn't aware of displaystyle(x) and textstyle(x) functions (any reason to prefer the former over the latter?). The behavior I was getting was because plotmath defaults to scriptstyle(x) or scriptscriptstyle(x)?
            – Indrajeet Patil
            Nov 10 at 13:22






          • 2




            @IndrajeetPatil, I immediately took displaystyle just because, in LaTeX documents, inline equations are somewhat smaller than display equations, and that's exactly the way to fix it there. Now it looks like textstyle is going to have somewhat less spacing, so you may see what you prefer. I'd guess that the default here is scriptstyle, and if you added, say, atop, it would be scriptscriptstyle.
            – Julius Vainora
            Nov 10 at 13:30










          • Thanks. See my second part to the current question: stackoverflow.com/questions/53239765/… Maybe you have some solution for this as well.
            – Indrajeet Patil
            Nov 10 at 14:08











          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',
          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%2f53235655%2fgetting-constant-text-size-while-using-atop-function-in-r%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








          up vote
          3
          down vote



          accepted










          I'm a little confused about the "substitute" in the plot, but perhaps the following solves the problem:



          ggplot(iris, aes(Species, Sepal.Length)) +
          geom_boxplot() +
          labs(caption = substitute(atop(
          atop(displaystyle("layer1"), displaystyle("layer2")), "layer3")))


          enter image description here






          share|improve this answer





















          • Cool. Wasn't aware of displaystyle(x) and textstyle(x) functions (any reason to prefer the former over the latter?). The behavior I was getting was because plotmath defaults to scriptstyle(x) or scriptscriptstyle(x)?
            – Indrajeet Patil
            Nov 10 at 13:22






          • 2




            @IndrajeetPatil, I immediately took displaystyle just because, in LaTeX documents, inline equations are somewhat smaller than display equations, and that's exactly the way to fix it there. Now it looks like textstyle is going to have somewhat less spacing, so you may see what you prefer. I'd guess that the default here is scriptstyle, and if you added, say, atop, it would be scriptscriptstyle.
            – Julius Vainora
            Nov 10 at 13:30










          • Thanks. See my second part to the current question: stackoverflow.com/questions/53239765/… Maybe you have some solution for this as well.
            – Indrajeet Patil
            Nov 10 at 14:08















          up vote
          3
          down vote



          accepted










          I'm a little confused about the "substitute" in the plot, but perhaps the following solves the problem:



          ggplot(iris, aes(Species, Sepal.Length)) +
          geom_boxplot() +
          labs(caption = substitute(atop(
          atop(displaystyle("layer1"), displaystyle("layer2")), "layer3")))


          enter image description here






          share|improve this answer





















          • Cool. Wasn't aware of displaystyle(x) and textstyle(x) functions (any reason to prefer the former over the latter?). The behavior I was getting was because plotmath defaults to scriptstyle(x) or scriptscriptstyle(x)?
            – Indrajeet Patil
            Nov 10 at 13:22






          • 2




            @IndrajeetPatil, I immediately took displaystyle just because, in LaTeX documents, inline equations are somewhat smaller than display equations, and that's exactly the way to fix it there. Now it looks like textstyle is going to have somewhat less spacing, so you may see what you prefer. I'd guess that the default here is scriptstyle, and if you added, say, atop, it would be scriptscriptstyle.
            – Julius Vainora
            Nov 10 at 13:30










          • Thanks. See my second part to the current question: stackoverflow.com/questions/53239765/… Maybe you have some solution for this as well.
            – Indrajeet Patil
            Nov 10 at 14:08













          up vote
          3
          down vote



          accepted







          up vote
          3
          down vote



          accepted






          I'm a little confused about the "substitute" in the plot, but perhaps the following solves the problem:



          ggplot(iris, aes(Species, Sepal.Length)) +
          geom_boxplot() +
          labs(caption = substitute(atop(
          atop(displaystyle("layer1"), displaystyle("layer2")), "layer3")))


          enter image description here






          share|improve this answer












          I'm a little confused about the "substitute" in the plot, but perhaps the following solves the problem:



          ggplot(iris, aes(Species, Sepal.Length)) +
          geom_boxplot() +
          labs(caption = substitute(atop(
          atop(displaystyle("layer1"), displaystyle("layer2")), "layer3")))


          enter image description here







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 10 at 9:04









          Julius Vainora

          27.6k75878




          27.6k75878












          • Cool. Wasn't aware of displaystyle(x) and textstyle(x) functions (any reason to prefer the former over the latter?). The behavior I was getting was because plotmath defaults to scriptstyle(x) or scriptscriptstyle(x)?
            – Indrajeet Patil
            Nov 10 at 13:22






          • 2




            @IndrajeetPatil, I immediately took displaystyle just because, in LaTeX documents, inline equations are somewhat smaller than display equations, and that's exactly the way to fix it there. Now it looks like textstyle is going to have somewhat less spacing, so you may see what you prefer. I'd guess that the default here is scriptstyle, and if you added, say, atop, it would be scriptscriptstyle.
            – Julius Vainora
            Nov 10 at 13:30










          • Thanks. See my second part to the current question: stackoverflow.com/questions/53239765/… Maybe you have some solution for this as well.
            – Indrajeet Patil
            Nov 10 at 14:08


















          • Cool. Wasn't aware of displaystyle(x) and textstyle(x) functions (any reason to prefer the former over the latter?). The behavior I was getting was because plotmath defaults to scriptstyle(x) or scriptscriptstyle(x)?
            – Indrajeet Patil
            Nov 10 at 13:22






          • 2




            @IndrajeetPatil, I immediately took displaystyle just because, in LaTeX documents, inline equations are somewhat smaller than display equations, and that's exactly the way to fix it there. Now it looks like textstyle is going to have somewhat less spacing, so you may see what you prefer. I'd guess that the default here is scriptstyle, and if you added, say, atop, it would be scriptscriptstyle.
            – Julius Vainora
            Nov 10 at 13:30










          • Thanks. See my second part to the current question: stackoverflow.com/questions/53239765/… Maybe you have some solution for this as well.
            – Indrajeet Patil
            Nov 10 at 14:08
















          Cool. Wasn't aware of displaystyle(x) and textstyle(x) functions (any reason to prefer the former over the latter?). The behavior I was getting was because plotmath defaults to scriptstyle(x) or scriptscriptstyle(x)?
          – Indrajeet Patil
          Nov 10 at 13:22




          Cool. Wasn't aware of displaystyle(x) and textstyle(x) functions (any reason to prefer the former over the latter?). The behavior I was getting was because plotmath defaults to scriptstyle(x) or scriptscriptstyle(x)?
          – Indrajeet Patil
          Nov 10 at 13:22




          2




          2




          @IndrajeetPatil, I immediately took displaystyle just because, in LaTeX documents, inline equations are somewhat smaller than display equations, and that's exactly the way to fix it there. Now it looks like textstyle is going to have somewhat less spacing, so you may see what you prefer. I'd guess that the default here is scriptstyle, and if you added, say, atop, it would be scriptscriptstyle.
          – Julius Vainora
          Nov 10 at 13:30




          @IndrajeetPatil, I immediately took displaystyle just because, in LaTeX documents, inline equations are somewhat smaller than display equations, and that's exactly the way to fix it there. Now it looks like textstyle is going to have somewhat less spacing, so you may see what you prefer. I'd guess that the default here is scriptstyle, and if you added, say, atop, it would be scriptscriptstyle.
          – Julius Vainora
          Nov 10 at 13:30












          Thanks. See my second part to the current question: stackoverflow.com/questions/53239765/… Maybe you have some solution for this as well.
          – Indrajeet Patil
          Nov 10 at 14:08




          Thanks. See my second part to the current question: stackoverflow.com/questions/53239765/… Maybe you have some solution for this as well.
          – Indrajeet Patil
          Nov 10 at 14:08


















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53235655%2fgetting-constant-text-size-while-using-atop-function-in-r%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

          Guess what letter conforming each word

          Port of Spain

          Run scheduled task as local user group (not BUILTIN)