Plot shifted t-distribution with ggplot2Rotating and spacing axis labels in ggplot2What do hjust and vjust do when making a plot using ggplot?Overlaying a normal distribution on a histogramPlot quantiles of distribution in ggplot2 with facetsIs there any “add” parameter (like in graphics::curve) for ggplot2?Illustrate mean and standard deviation in ggplot2 density plotHow to plot a set of rotated densities in ggplot2?Trying to add normal distribution curve to ggplot, and it's not workingggplot - altering the height of each overlapping variable on a density plotHow to plot two distribution curves in a faceted way in R / ggplot2?

Why is an old chain unsafe?

How can the DM most effectively choose 1 out of an odd number of players to be targeted by an attack or effect?

Japan - Plan around max visa duration

Can I make popcorn with any corn?

What Brexit solution does the DUP want?

What defenses are there against being summoned by the Gate spell?

Is it possible to make sharp wind that can cut stuff from afar?

A newer friend of my brother's gave him a load of baseball cards that are supposedly extremely valuable. Is this a scam?

How does one intimidate enemies without having the capacity for violence?

Why is "Reports" in sentence down without "The"

I’m planning on buying a laser printer but concerned about the life cycle of toner in the machine

Shell script can be run only with sh command

Can a German sentence have two subjects?

What is the offset in a seaplane's hull?

Why are 150k or 200k jobs considered good when there are 300k+ births a month?

The magic money tree problem

Extreme, but not acceptable situation and I can't start the work tomorrow morning

Why has Russell's definition of numbers using equivalence classes been finally abandoned? ( If it has actually been abandoned).

Email Account under attack (really) - anything I can do?

Why don't electron-positron collisions release infinite energy?

Example of a relative pronoun

DOS, create pipe for stdin/stdout of command.com(or 4dos.com) in C or Batch?

Is Social Media Science Fiction?

Why CLRS example on residual networks does not follows its formula?



Plot shifted t-distribution with ggplot2


Rotating and spacing axis labels in ggplot2What do hjust and vjust do when making a plot using ggplot?Overlaying a normal distribution on a histogramPlot quantiles of distribution in ggplot2 with facetsIs there any “add” parameter (like in graphics::curve) for ggplot2?Illustrate mean and standard deviation in ggplot2 density plotHow to plot a set of rotated densities in ggplot2?Trying to add normal distribution curve to ggplot, and it's not workingggplot - altering the height of each overlapping variable on a density plotHow to plot two distribution curves in a faceted way in R / ggplot2?






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








0















I am trying to plot the density curve of a t-distribution with mean = 3 and df = 1.5 using ggplot2. However it is supposed to be symmetric around 3, so I can not use the noncentrality parameter.



ggplot(data.frame(x = c(-4, 10)), aes(x = x)) +
stat_function(fun = dt, args = list(df = 1.5))


Is there a way to simply shift the distribution along the x-axis?










share|improve this question




























    0















    I am trying to plot the density curve of a t-distribution with mean = 3 and df = 1.5 using ggplot2. However it is supposed to be symmetric around 3, so I can not use the noncentrality parameter.



    ggplot(data.frame(x = c(-4, 10)), aes(x = x)) +
    stat_function(fun = dt, args = list(df = 1.5))


    Is there a way to simply shift the distribution along the x-axis?










    share|improve this question
























      0












      0








      0








      I am trying to plot the density curve of a t-distribution with mean = 3 and df = 1.5 using ggplot2. However it is supposed to be symmetric around 3, so I can not use the noncentrality parameter.



      ggplot(data.frame(x = c(-4, 10)), aes(x = x)) +
      stat_function(fun = dt, args = list(df = 1.5))


      Is there a way to simply shift the distribution along the x-axis?










      share|improve this question














      I am trying to plot the density curve of a t-distribution with mean = 3 and df = 1.5 using ggplot2. However it is supposed to be symmetric around 3, so I can not use the noncentrality parameter.



      ggplot(data.frame(x = c(-4, 10)), aes(x = x)) +
      stat_function(fun = dt, args = list(df = 1.5))


      Is there a way to simply shift the distribution along the x-axis?







      r ggplot2






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Feb 3 '17 at 14:23









      nhoeftnhoeft

      15012




      15012






















          3 Answers
          3






          active

          oldest

          votes


















          4














          you could also make a custom function for your shifted t-distribution:



          custom <- function(x) dt(x - 3, 1.5)
          ggplot(data.frame(x = c(-4, 10)), aes(x = x)) +
          stat_function(fun = custom)





          share|improve this answer






























            1














            A simple solution is to just change the labels instead:



            ggplot(data.frame(x = c(-4, 10)), aes(x = x)) +
            stat_function(fun = dt, args = list(df = 1.5)) +
            scale_x_continuous(breaks = c(0, 5, 10), labels = c(3, 8, 13))





            share|improve this answer






























              0














              There is also a function dt.scaled in the metRology package, which in addition to the df, lets you specify the mean and scale.



              Relevant code:



              dt.scaled <- function(x, df, mean = 0, sd = 1, ncp, log = FALSE) 
              if (!log) stats::dt((x - mean)/sd, df, ncp = ncp, log = FALSE)/sd
              else stats::dt((x - mean)/sd, df, ncp = ncp, log = TRUE) - log(sd)






              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%2f42026421%2fplot-shifted-t-distribution-with-ggplot2%23new-answer', 'question_page');

                );

                Post as a guest















                Required, but never shown

























                3 Answers
                3






                active

                oldest

                votes








                3 Answers
                3






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                4














                you could also make a custom function for your shifted t-distribution:



                custom <- function(x) dt(x - 3, 1.5)
                ggplot(data.frame(x = c(-4, 10)), aes(x = x)) +
                stat_function(fun = custom)





                share|improve this answer



























                  4














                  you could also make a custom function for your shifted t-distribution:



                  custom <- function(x) dt(x - 3, 1.5)
                  ggplot(data.frame(x = c(-4, 10)), aes(x = x)) +
                  stat_function(fun = custom)





                  share|improve this answer

























                    4












                    4








                    4







                    you could also make a custom function for your shifted t-distribution:



                    custom <- function(x) dt(x - 3, 1.5)
                    ggplot(data.frame(x = c(-4, 10)), aes(x = x)) +
                    stat_function(fun = custom)





                    share|improve this answer













                    you could also make a custom function for your shifted t-distribution:



                    custom <- function(x) dt(x - 3, 1.5)
                    ggplot(data.frame(x = c(-4, 10)), aes(x = x)) +
                    stat_function(fun = custom)






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Feb 3 '17 at 14:42









                    NateNate

                    6,71512030




                    6,71512030























                        1














                        A simple solution is to just change the labels instead:



                        ggplot(data.frame(x = c(-4, 10)), aes(x = x)) +
                        stat_function(fun = dt, args = list(df = 1.5)) +
                        scale_x_continuous(breaks = c(0, 5, 10), labels = c(3, 8, 13))





                        share|improve this answer



























                          1














                          A simple solution is to just change the labels instead:



                          ggplot(data.frame(x = c(-4, 10)), aes(x = x)) +
                          stat_function(fun = dt, args = list(df = 1.5)) +
                          scale_x_continuous(breaks = c(0, 5, 10), labels = c(3, 8, 13))





                          share|improve this answer

























                            1












                            1








                            1







                            A simple solution is to just change the labels instead:



                            ggplot(data.frame(x = c(-4, 10)), aes(x = x)) +
                            stat_function(fun = dt, args = list(df = 1.5)) +
                            scale_x_continuous(breaks = c(0, 5, 10), labels = c(3, 8, 13))





                            share|improve this answer













                            A simple solution is to just change the labels instead:



                            ggplot(data.frame(x = c(-4, 10)), aes(x = x)) +
                            stat_function(fun = dt, args = list(df = 1.5)) +
                            scale_x_continuous(breaks = c(0, 5, 10), labels = c(3, 8, 13))






                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Feb 3 '17 at 14:35









                            AxemanAxeman

                            19.3k54559




                            19.3k54559





















                                0














                                There is also a function dt.scaled in the metRology package, which in addition to the df, lets you specify the mean and scale.



                                Relevant code:



                                dt.scaled <- function(x, df, mean = 0, sd = 1, ncp, log = FALSE) 
                                if (!log) stats::dt((x - mean)/sd, df, ncp = ncp, log = FALSE)/sd
                                else stats::dt((x - mean)/sd, df, ncp = ncp, log = TRUE) - log(sd)






                                share|improve this answer



























                                  0














                                  There is also a function dt.scaled in the metRology package, which in addition to the df, lets you specify the mean and scale.



                                  Relevant code:



                                  dt.scaled <- function(x, df, mean = 0, sd = 1, ncp, log = FALSE) 
                                  if (!log) stats::dt((x - mean)/sd, df, ncp = ncp, log = FALSE)/sd
                                  else stats::dt((x - mean)/sd, df, ncp = ncp, log = TRUE) - log(sd)






                                  share|improve this answer

























                                    0












                                    0








                                    0







                                    There is also a function dt.scaled in the metRology package, which in addition to the df, lets you specify the mean and scale.



                                    Relevant code:



                                    dt.scaled <- function(x, df, mean = 0, sd = 1, ncp, log = FALSE) 
                                    if (!log) stats::dt((x - mean)/sd, df, ncp = ncp, log = FALSE)/sd
                                    else stats::dt((x - mean)/sd, df, ncp = ncp, log = TRUE) - log(sd)






                                    share|improve this answer













                                    There is also a function dt.scaled in the metRology package, which in addition to the df, lets you specify the mean and scale.



                                    Relevant code:



                                    dt.scaled <- function(x, df, mean = 0, sd = 1, ncp, log = FALSE) 
                                    if (!log) stats::dt((x - mean)/sd, df, ncp = ncp, log = FALSE)/sd
                                    else stats::dt((x - mean)/sd, df, ncp = ncp, log = TRUE) - log(sd)







                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered Mar 9 at 3:37









                                    kwiebelskwiebels

                                    1




                                    1



























                                        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%2f42026421%2fplot-shifted-t-distribution-with-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

                                        Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme

                                        Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

                                        2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived