2

I have a regression that has the following simple format: ln(Y) = C + lf(X). It's estimated as ln(Y) = 0.62 + 0.81. I want to plot it for a range of values for X (0 to 50) and compare it with a 45 degree line to see where it turns.

How can I create a plot (or a scatterplot) that shows something like this? A scatterplot with two series might do it: one for (x,x) with X going from 0 to 50 and a second with (x,y) with X going from 0 to 50 and y as calculated with the line above ln(y) = 0.62+0.81.

How can I do something like this?

\documentclass[border=2pt]{standalone}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{axis}
%For x = 0 to 50, plot Y = exp(0.81 + 0.62X)    
%From x = 0 to 50, plot a 45 degree line straight from the origin for comparison
    \addplot 
\end{axis}
\end{tikzpicture}
\end{document}

1 Answer 1

4

You have two options for the exponential function:

  1. Crank samples up to 500 or so
  2. Use samples at and determine, where the exponential function is 50.

\documentclass[tikz,border=2pt]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
    \begin{axis}[
        no markers,
        domain=0:50,
        restrict y to domain=0:50,
        legend pos=south east,
    ]
        \addplot {x};
        \addplot+[smooth,samples at={0,1,2,3,4,5}] {exp(0.81 + 0.62*x)};
        \legend{$45^\circ$ line,$\exp(0.81 + 0.62 x)$},
    \end{axis}
\end{tikzpicture}
\end{document}

enter image description here

2
  • Sorry: I should have clarified. The 45 degree line is fine. The other line should have be filled with values as follows: (X,Y) where X is from 0 to 50 and Y is exp(0.62 + 0.81X). Mar 17, 2014 at 17:22
  • 1
    @user2146441 Aha! You dropped the x in your question. Mar 17, 2014 at 17:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .