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 7924329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:42:26+00:00 2026-06-03T17:42:26+00:00

I want to add a exponential (+ power) (trend) line to my plot. I

  • 0

I want to add a exponential (+ power) (trend) line to my plot. I am using ggplot2 package.

I have something like this (just with much more data):

require(ggplot2)

df <-read.table("test.csv", header = TRUE, sep = ",")
df
    meta temp
1  1.283    6
2  0.642    6
3  1.962    6
4  8.989   25
5  8.721   25
6 12.175   25
7 11.676   32
8 12.131   32
9 11.576   32

ggplot(df, aes(temp, meta)) + 
    ylab("Metabolism") + xlab("Temperature") +
    geom_point() + 
    theme_bw() + 
    scale_x_continuous(limits = c(0, 35)) + 
    scale_y_log10()

I know that this should be expressed with an exponential function – so my question is how I can ad the best ‘exponential’ fit? Likewise, is it possible to make a power-fit too?

Does the stat_smooth() function have this opportunity, or are there other functions in ggplot2 package I should use?

  • 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-03T17:42:27+00:00Added an answer on June 3, 2026 at 5:42 pm

    You can specify the model to fit as an argument to stat_smooth by passing two arguments:

    • method, e.g. method="lm"
    • model, e.g. model = log(y) ~ x

    ggplot2 first does the scale transformation and then fits the model, so in your example you simply have to add

    + stat_smooth(method="lm")
    

    to your plot:

    library(ggplot2)
    ggplot(df, aes(temp, meta)) + 
        ylab("Metabolism") + xlab("Temperature") +
        geom_point() + 
        theme_bw() + 
        scale_x_continuous(limits = c(0, 35)) + 
        scale_y_log10() +
        stat_smooth(method="lm")
    

    enter image description here


    Similarly, fitting and plotting a power curve is as simple as changing your x-scale to log:

    ggplot(df, aes(temp, meta)) + 
        ylab("Metabolism") + xlab("Temperature") +
        geom_point() + 
        theme_bw() + 
        scale_x_log10() + 
        scale_y_log10() +
        stat_smooth(method="lm")
    

    enter image description here

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

Sidebar

Related Questions

I have an image of polyline but I want add this poly line image
I have a report that I want add a line beneath the even rows
I have a problem with this: I want add :onchange => readURL(this) to my:
I want add my custom sidebar next right column all page. Please check this
I have a website built with ASP.NET (3.5) and want add some level of
I have a list of string values that I want add to a hashtable
I have numbers in javascript from 01(int) to 09(int) and I want add 1(int)
I used RollingFileAppender. And I want add a blank line to the log when
Why i have an error in my web.xml when i want add servlet..? <servlet>
I have a table with some rows and inputs inside them. I want add

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.