[Tex/LaTex] How to make sigmoid function at Tikz

graphstikz-pgf

I'm trying to make something like this at Tikz:

The function is:
y=1/(1+e^(-x))

enter image description here

but I don't know how to do it because the axis are at different scales.
Can you help me with it?

Thank you!

P.S. I'd like to add the axis with the numbers and help grids (if it's possible).

Source of the graph

Best Answer

Here's an example of your function using the pgfplots package:

\documentclass{standalone}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
    \begin{axis}[
        title = {sigmoid function},
        axis on top = true,
        axis x line = bottom,
        axis y line = left,
        grid = major,
        xlabel = $Z$
    ]
        \addplot[
            blue,
            domain = -5:5,
            samples = 100
        ]
            {1/(1+exp(-x))};
    \end{axis}
\end{tikzpicture}
\end{document}

plot1

The axis settings (range, grid, appearance, ..) can be defined in the optional argument of the axis environment. Inside the axis environment you can plot multiple curves or data point series using \addplot macros.

Edit

Here's a version using pgfplots which looks more similar to your example:

\documentclass{standalone}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
    \begin{axis}[
        height = 7.3cm,
        width = 11cm,
        title = {sigmoid function},
        axis on top = true,
        axis x line = bottom,
        axis y line = left,
        x axis line style = -,
        y axis line style = -,
        tick align = outside,
        every tick/.append style = {
            black,
            thin
        },
%       grid = major,
        ymin = 0,
        ymax = 1,
        xlabel = $Z$
    ]
        \addplot[
            blue,
            domain = -5:5,
            samples = 100
        ]
            {1/(1+exp(-x))};
    \end{axis}
\end{tikzpicture}
\end{document}

plot2

Related Question