Force R to stop plotting abbreviated axis labels - e.g. 1e+00 in ggplot2










70















In ggplot2 how can I stop axis labels being abbreviated - e.g. 1e+00, 1e+01 along the x axis once plotted? Ideally, I want to force R to display the actual values which in this case would be 1,10.



Any help much appreciated.










share|improve this question


























    70















    In ggplot2 how can I stop axis labels being abbreviated - e.g. 1e+00, 1e+01 along the x axis once plotted? Ideally, I want to force R to display the actual values which in this case would be 1,10.



    Any help much appreciated.










    share|improve this question
























      70












      70








      70


      17






      In ggplot2 how can I stop axis labels being abbreviated - e.g. 1e+00, 1e+01 along the x axis once plotted? Ideally, I want to force R to display the actual values which in this case would be 1,10.



      Any help much appreciated.










      share|improve this question














      In ggplot2 how can I stop axis labels being abbreviated - e.g. 1e+00, 1e+01 along the x axis once plotted? Ideally, I want to force R to display the actual values which in this case would be 1,10.



      Any help much appreciated.







      r graph ggplot2 axes






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 28 '13 at 14:17









      JPDJPD

      76631124




      76631124






















          4 Answers
          4






          active

          oldest

          votes


















          92














          I think you are looking for this:



          require(ggplot2)
          df <- data.frame(x=seq(1, 1e9, length.out=100), y=sample(100))
          # displays x-axis in scientific notation
          p <- ggplot(data = df, aes(x=x, y=y)) + geom_line() + geom_point()
          p

          # displays as you require
          require(scales)
          p + scale_x_continuous(labels = comma)





          share|improve this answer

























          • This worked. Thank you. Out of interest, what other 'label' options are there for axes in ggplot2 with the scales package?

            – JPD
            Jan 28 '13 at 14:28







          • 1





            Please visit also this ggplot2.org page, it was very helpful for me with a similar issue.

            – Marta Karas
            Jul 30 '14 at 10:42



















          47














          Did you try something like :



          options(scipen=10000)


          before plotting ?






          share|improve this answer


















          • 2





            This works by setting a higher penalty for deciding to use scientific notation. More explanation in this answer: stackoverflow.com/a/18600721/1080804

            – ecoe
            Jul 4 '16 at 14:09


















          20














          Just an update to what @Arun made, since I tried it today and it didn't work because it was actualized to



          + scale_x_continuous(labels = scales::comma)





          share|improve this answer
































            7














            As a more general solution, you can use scales::format_format to remove the scientific notation. This also gives you lots of control around how exactly you want your labels to be displayed, as opposed to scales::comma which only does comma separations of the orders of magnitude.



            For example:



            require(ggplot2)
            require(scales)
            df <- data.frame(x=seq(1, 1e9, length.out=100), y=sample(100))

            # Here we define spaces as the big separator
            point <- format_format(big.mark = " ", decimal.mark = ",", scientific = FALSE)

            # Plot it
            p <- ggplot(data = df, aes(x=x, y=y)) + geom_line() + geom_point()
            p + scale_x_continuous(labels = point)





            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%2f14563989%2fforce-r-to-stop-plotting-abbreviated-axis-labels-e-g-1e00-in-ggplot2%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              4 Answers
              4






              active

              oldest

              votes








              4 Answers
              4






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              92














              I think you are looking for this:



              require(ggplot2)
              df <- data.frame(x=seq(1, 1e9, length.out=100), y=sample(100))
              # displays x-axis in scientific notation
              p <- ggplot(data = df, aes(x=x, y=y)) + geom_line() + geom_point()
              p

              # displays as you require
              require(scales)
              p + scale_x_continuous(labels = comma)





              share|improve this answer

























              • This worked. Thank you. Out of interest, what other 'label' options are there for axes in ggplot2 with the scales package?

                – JPD
                Jan 28 '13 at 14:28







              • 1





                Please visit also this ggplot2.org page, it was very helpful for me with a similar issue.

                – Marta Karas
                Jul 30 '14 at 10:42
















              92














              I think you are looking for this:



              require(ggplot2)
              df <- data.frame(x=seq(1, 1e9, length.out=100), y=sample(100))
              # displays x-axis in scientific notation
              p <- ggplot(data = df, aes(x=x, y=y)) + geom_line() + geom_point()
              p

              # displays as you require
              require(scales)
              p + scale_x_continuous(labels = comma)





              share|improve this answer

























              • This worked. Thank you. Out of interest, what other 'label' options are there for axes in ggplot2 with the scales package?

                – JPD
                Jan 28 '13 at 14:28







              • 1





                Please visit also this ggplot2.org page, it was very helpful for me with a similar issue.

                – Marta Karas
                Jul 30 '14 at 10:42














              92












              92








              92







              I think you are looking for this:



              require(ggplot2)
              df <- data.frame(x=seq(1, 1e9, length.out=100), y=sample(100))
              # displays x-axis in scientific notation
              p <- ggplot(data = df, aes(x=x, y=y)) + geom_line() + geom_point()
              p

              # displays as you require
              require(scales)
              p + scale_x_continuous(labels = comma)





              share|improve this answer















              I think you are looking for this:



              require(ggplot2)
              df <- data.frame(x=seq(1, 1e9, length.out=100), y=sample(100))
              # displays x-axis in scientific notation
              p <- ggplot(data = df, aes(x=x, y=y)) + geom_line() + geom_point()
              p

              # displays as you require
              require(scales)
              p + scale_x_continuous(labels = comma)






              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Jan 30 at 20:42









              Dave Jarvis

              21.1k30132256




              21.1k30132256










              answered Jan 28 '13 at 14:23









              ArunArun

              93.6k11218319




              93.6k11218319












              • This worked. Thank you. Out of interest, what other 'label' options are there for axes in ggplot2 with the scales package?

                – JPD
                Jan 28 '13 at 14:28







              • 1





                Please visit also this ggplot2.org page, it was very helpful for me with a similar issue.

                – Marta Karas
                Jul 30 '14 at 10:42


















              • This worked. Thank you. Out of interest, what other 'label' options are there for axes in ggplot2 with the scales package?

                – JPD
                Jan 28 '13 at 14:28







              • 1





                Please visit also this ggplot2.org page, it was very helpful for me with a similar issue.

                – Marta Karas
                Jul 30 '14 at 10:42

















              This worked. Thank you. Out of interest, what other 'label' options are there for axes in ggplot2 with the scales package?

              – JPD
              Jan 28 '13 at 14:28






              This worked. Thank you. Out of interest, what other 'label' options are there for axes in ggplot2 with the scales package?

              – JPD
              Jan 28 '13 at 14:28





              1




              1





              Please visit also this ggplot2.org page, it was very helpful for me with a similar issue.

              – Marta Karas
              Jul 30 '14 at 10:42






              Please visit also this ggplot2.org page, it was very helpful for me with a similar issue.

              – Marta Karas
              Jul 30 '14 at 10:42














              47














              Did you try something like :



              options(scipen=10000)


              before plotting ?






              share|improve this answer


















              • 2





                This works by setting a higher penalty for deciding to use scientific notation. More explanation in this answer: stackoverflow.com/a/18600721/1080804

                – ecoe
                Jul 4 '16 at 14:09















              47














              Did you try something like :



              options(scipen=10000)


              before plotting ?






              share|improve this answer


















              • 2





                This works by setting a higher penalty for deciding to use scientific notation. More explanation in this answer: stackoverflow.com/a/18600721/1080804

                – ecoe
                Jul 4 '16 at 14:09













              47












              47








              47







              Did you try something like :



              options(scipen=10000)


              before plotting ?






              share|improve this answer













              Did you try something like :



              options(scipen=10000)


              before plotting ?







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Jan 28 '13 at 14:19









              jubajuba

              34.5k888100




              34.5k888100







              • 2





                This works by setting a higher penalty for deciding to use scientific notation. More explanation in this answer: stackoverflow.com/a/18600721/1080804

                – ecoe
                Jul 4 '16 at 14:09












              • 2





                This works by setting a higher penalty for deciding to use scientific notation. More explanation in this answer: stackoverflow.com/a/18600721/1080804

                – ecoe
                Jul 4 '16 at 14:09







              2




              2





              This works by setting a higher penalty for deciding to use scientific notation. More explanation in this answer: stackoverflow.com/a/18600721/1080804

              – ecoe
              Jul 4 '16 at 14:09





              This works by setting a higher penalty for deciding to use scientific notation. More explanation in this answer: stackoverflow.com/a/18600721/1080804

              – ecoe
              Jul 4 '16 at 14:09











              20














              Just an update to what @Arun made, since I tried it today and it didn't work because it was actualized to



              + scale_x_continuous(labels = scales::comma)





              share|improve this answer





























                20














                Just an update to what @Arun made, since I tried it today and it didn't work because it was actualized to



                + scale_x_continuous(labels = scales::comma)





                share|improve this answer



























                  20












                  20








                  20







                  Just an update to what @Arun made, since I tried it today and it didn't work because it was actualized to



                  + scale_x_continuous(labels = scales::comma)





                  share|improve this answer















                  Just an update to what @Arun made, since I tried it today and it didn't work because it was actualized to



                  + scale_x_continuous(labels = scales::comma)






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Nov 15 '18 at 14:59









                  alessandra

                  52




                  52










                  answered Mar 16 '17 at 16:59









                  Derek CorcoranDerek Corcoran

                  1,69911225




                  1,69911225





















                      7














                      As a more general solution, you can use scales::format_format to remove the scientific notation. This also gives you lots of control around how exactly you want your labels to be displayed, as opposed to scales::comma which only does comma separations of the orders of magnitude.



                      For example:



                      require(ggplot2)
                      require(scales)
                      df <- data.frame(x=seq(1, 1e9, length.out=100), y=sample(100))

                      # Here we define spaces as the big separator
                      point <- format_format(big.mark = " ", decimal.mark = ",", scientific = FALSE)

                      # Plot it
                      p <- ggplot(data = df, aes(x=x, y=y)) + geom_line() + geom_point()
                      p + scale_x_continuous(labels = point)





                      share|improve this answer



























                        7














                        As a more general solution, you can use scales::format_format to remove the scientific notation. This also gives you lots of control around how exactly you want your labels to be displayed, as opposed to scales::comma which only does comma separations of the orders of magnitude.



                        For example:



                        require(ggplot2)
                        require(scales)
                        df <- data.frame(x=seq(1, 1e9, length.out=100), y=sample(100))

                        # Here we define spaces as the big separator
                        point <- format_format(big.mark = " ", decimal.mark = ",", scientific = FALSE)

                        # Plot it
                        p <- ggplot(data = df, aes(x=x, y=y)) + geom_line() + geom_point()
                        p + scale_x_continuous(labels = point)





                        share|improve this answer

























                          7












                          7








                          7







                          As a more general solution, you can use scales::format_format to remove the scientific notation. This also gives you lots of control around how exactly you want your labels to be displayed, as opposed to scales::comma which only does comma separations of the orders of magnitude.



                          For example:



                          require(ggplot2)
                          require(scales)
                          df <- data.frame(x=seq(1, 1e9, length.out=100), y=sample(100))

                          # Here we define spaces as the big separator
                          point <- format_format(big.mark = " ", decimal.mark = ",", scientific = FALSE)

                          # Plot it
                          p <- ggplot(data = df, aes(x=x, y=y)) + geom_line() + geom_point()
                          p + scale_x_continuous(labels = point)





                          share|improve this answer













                          As a more general solution, you can use scales::format_format to remove the scientific notation. This also gives you lots of control around how exactly you want your labels to be displayed, as opposed to scales::comma which only does comma separations of the orders of magnitude.



                          For example:



                          require(ggplot2)
                          require(scales)
                          df <- data.frame(x=seq(1, 1e9, length.out=100), y=sample(100))

                          # Here we define spaces as the big separator
                          point <- format_format(big.mark = " ", decimal.mark = ",", scientific = FALSE)

                          # Plot it
                          p <- ggplot(data = df, aes(x=x, y=y)) + geom_line() + geom_point()
                          p + scale_x_continuous(labels = point)






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Nov 28 '17 at 17:34









                          user2739472user2739472

                          52858




                          52858



























                              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%2f14563989%2fforce-r-to-stop-plotting-abbreviated-axis-labels-e-g-1e00-in-ggplot2%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

                              Top Tejano songwriter Luis Silva dead of heart attack at 64

                              政党

                              天津地下鉄3号線