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

                                        Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

                                        Understanding generators in Python2019 Community Moderator ElectionGenerator function not working pythonFor loop not executing two timesGenerators - Printing generated valuesWhy can a python generator only be used once?What exactly do generators do?What does the “yield” keyword do?What does “list comprehension” mean? How does it work and how can I use it?sklearn Kfold acces single fold instead of for loopIs a generator the callable? Which is the generator?Apply Border To Range Of Cells Using OpenpyxlCalling an external command in PythonWhat are metaclasses in Python?What is the difference between @staticmethod and @classmethod?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?Understanding slice notationUnderstanding Python super() with __init__() methodsDoes Python have a string 'contains' substring method?

                                        How can I change the color of pagination dots of UIPageControl?How to change UIPageControl dotsIs there a way to change page indicator dots colorCustomize dot with image of UIPageControl at index 0 of UIPageControlNo visible @interface for 'NSObject<PageControlDelegate>' declares the selector 'pageControlPageDidChange:'How to change the color of pagination dots in UIPageControl with a different color per pagepagecontrol indicator custom image instead of DefaultChanging the colour of UIPageControl dots in MonoTouchpagecontrol selectable page visibility color?Alternative way to load ViewControllers on a UIPageControlHow to set only layer.border-color for UIpage control dots in swiftHow can I develop for iPhone using a Windows development machine?How to change the name of an iOS app?UITableView - change section header coloruipagecontrol indicator(dot)issueCustom UIPageControl dots color not changingchange the interspace between UIPageControl dotsHow to change Status Bar text color in iOSHow can I change image tintColor in iOS and WatchKitUIPageControl dots with larger space in between each dotsHow to change the color of pagination dots in UIPageControl with a different color per page