# How to correctly plot function with space?

I want to include some plots of some functions which approaches certain values. See the screenshot below of tanh.

For clarity I have added some space left and right (see screenshot + MWE below).

However I think this is not correct, because this suggest that e.g. x=4.2 is outside the domain which is not te case.

How is this typically solved? Is this just fine (I am too critical), or is this solved on an another way (add plot domain in legend, different setup)?

Thanks

Screenshot: MWE:

    \documentclass{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}[ baseline]
\begin{axis}[xmin=-5,xmax=5,ymin=-1.5,ymax=1.5,xlabel=$x$,ylabel=$\phi(x)$,enlargelimits=false]
\end{axis}
\end{tikzpicture}
\end{document}

• \begin{tikzpicture} \begin{axis}[xlabel=$x$,ylabel=$\phi(x)$] \addplot[domain=-4:4]{(e^\x-e^-\x)/(e^\x+e^-\x)}; \end{axis} \end{tikzpicture} would be enough to type here. Just add the information of your domain to the axis title or in your caption or legend. This really does not matter. Or you add a bit of a dotted curve with greater domain below. As it stands now, it has nothing to do with LaTeX. I will vote as off-topic though. Sep 14 '15 at 11:40

One thing you could do is plot the graph 2 extra times with another domain and linestyle (gray, dashdotted or anything you like) with domains <-4 and >4.

    \addplot[domain=-4:4,  black]{(e^\x-e^-\x)/(e^\x+e^-\x)};


Otherwise I would say that it looks fine as it is. You could always specify in your text what the figure illustrates, as long as the values outside the figure are not too relevant with your text.

If you increase the number of samples, you just need to print two curves (see Robin's answer)

% arara: pdflatex

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}

\begin{document}
\begin{tikzpicture}
\begin{axis}[xlabel=$x$,ylabel=$\phi(x)$] 