Search code examples
latexpgfplots

Latex pgfplots cannot show the line


I am trying to plot a graph like this in Latex:
enter image description here It turns out to be looking like this with out a line:
enter image description here

This is my tex file

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}
\pgfplotsset{compat=1.5}

\begin{document}
\begin{center}
\begin{tikzpicture}
\begin{axis}[
    axis lines = left,
    ytick={0,0.25},
    xtick={0,2,4,6,8,10},
    height=5.5cm,
    width=13cm,
    xmax=10,
    ymax=0.25,
    ymin=0,
    xmin=0,
    xlabel = T,
    ylabel = k,
]

\addplot [
    domain=0:100, 
    samples=1000, 
    color=blue,
    ]
    {0.001^(x/x+1) * (1+x)};
\addlegendentry{\(T=p^{\frac{k}{k+1}(k+1)}\)}

\end{axis}
\end{tikzpicture}
\end{center}

\end{document}

Have I done any thing wrong? Thank you.


Solution

  • Simple math problem: (x/x+1) != (x/(x+1))

    \documentclass{article}
    \usepackage[utf8]{inputenc}
    \usepackage{pgfplots}
    \pgfplotsset{compat=1.5}
    
    \begin{document}
    \begin{center}
    \begin{tikzpicture}
    \begin{axis}[
        axis lines = left,
        height=5.5cm,
        width=13cm,
        xlabel = T,
        ylabel = k,
    ]
    
    \addplot [
        domain=0:10, 
        samples=100, 
        color=blue,
        ]
        { (1+x)*0.001^(x/(x+1)) };
    \addlegendentry{\(T=p^{\frac{k}{k+1}}(k+1)\)}
    
    \end{axis}
    \end{tikzpicture}
    \end{center}
    
    \end{document}
    

    enter image description here