Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8537209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:50:46+00:00 2026-06-11T10:50:46+00:00

I try to superimpose a function via stat_function() in ggplot but can’t figure out

  • 0

I try to superimpose a function via stat_function() in ggplot but can’t figure out my mistake. this example produces a nice looking plot:

data <- data.frame(x=rt(10000, df=7))

ggplot(data=data, aes(x=x)) + geom_histogram(aes(y = ..density..)) +
  stat_function(fun =dnorm, size=1, color='gray', args=list()) +
  opts(title="Histogram of interest rate changes") + theme_bw()

enter image description here

but when i try to superimpose a log-normal density this doesn’t work as expected (or should I say as expected this doesn’t work ;):

data <- data.frame(x=rf(10000, df1=7, df2=120))

ggplot(data=data, aes(x=x)) + geom_histogram(aes(y = ..density..)) +
 stat_function(fun =dnorm, size=1, color='gray', args=list(log=TRUE)) +
 opts(title="Histogram of interest rate changes") + theme_bw()

enter image description here

so here’s my hopefully simple question: what am I doing wrong here? I guess this is a really simple problem I just don’t see the answer – sorry.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T10:50:47+00:00Added an answer on June 11, 2026 at 10:50 am

    Use dlnorm, the density function of the log-normal distribution:

    ggplot(data=data, aes(x=x)) + geom_histogram(aes(y = ..density..)) +
      stat_function(fun = dlnorm, size=1, color='gray') +
      opts(title="Histogram of interest rate changes") + theme_bw()
    

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Try yourself : as example, try to retrieve the fields of this video :
Try to find a global function, to get and to put the backgroundPosition-values, but
Try this: $test = array (2+2); var_dump($test); Then try the same but inside a
Try this out: template <typename T> class Base { public: int someBaseMember; }; template
Try this in chrome versus firefox/IE: var cancelPressed = false; function redirect() { //window.location
Try this code - import java.io.StringReader; public class StringReaderTest { public static void main(String[]
Try this piece of code - public class WhitespaceTest { public static void main(String[]
try: recursive_function() except RuntimeError e: # is this a max. recursion depth exceeded exception?
try { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); System.out.println(Enter the continent;); String CN =
Try to open my web-page on vds and then get: We're sorry, but something

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.