Can someone help me to plot the graph of tanh in latex. I know I have to use pgfplot but I do not know actually how to use it. Any type of help is appreciated.

  • 2
    Welcome to TeX.SX! You can have a look on our starter guide to familiarize yourself further with our format. Have a look at the manual texdoc pgfplots which should give you plenty of examples - you should be able to copy and paste from it into a document on your system, which will give you a starting point – cmhughes May 8 '14 at 17:17

I'd definitely recommend using pgfplots:

enter image description here



    xmin=-2.5, xmax=2.5,
    ymin=-1.5, ymax=1.5,
    axis lines=center,
    axis on top=true,

    \addplot [mark=none,draw=red,ultra thick] {tanh(\x)};
    \node [right, red] at (axis cs: 1,0.7) {$y = \tanh x$};

    %% Add the asymptotes
    \draw [blue, dotted, thick] (axis cs:-2.5,-1)-- (axis cs:0,-1);
    \draw [blue, dotted, thick] (axis cs:+2.5,+1)-- (axis cs:0,+1);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.