# Packages to plot functions such as the logistic function (or “S-shaped function”)?

Is it possible to plot the graph of an S-shaped function in LaTeX? If yes, then how? Which packages should I use for that?

-
Welcome to TeX, could you please provide what an S-shaped graph is? I must admit I have no clue what it is? –  zeroth Aug 16 '13 at 10:53
Please give a picture of what you mean. Also, it would be nice to post the code starting from \documentclass{...} and ending at \end{document} to show what you have tried and it will save those who want to help, some typing work and guessing. –  Harish Kumar Aug 16 '13 at 10:55
Are you talking about the logistic function? –  Jubobs Aug 16 '13 at 10:58
For different ways to plot functions in latex see tex.stackexchange.com/q/3622/15925 –  Andrew Swann Aug 16 '13 at 11:10
yes i am talking about the graph of logistic functions.i.e. a non-linear s-shape function.. –  Misha Aug 16 '13 at 11:10

The pgfplots package is really handy for that type of graphs. I invite you to have a look at the documentation, which is really well written, with many detailed examples.

Note that, on this site, a question should typically revolve around an abstract issue (e.g. "How do I get a double horizontal line in a table?") rather than a concrete application (e.g. "How do I make this table?"). Please try to make your question clear and simple by giving a minimal working example (MWE): you'll stand a greater chance of getting help.

However, since you're a new TeX.SE user, I'd like to get you started with pgfplots. Below is some code that reproduces the graph available on the Wikipedia page on the logistic function (also called "S-shaped function").

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}
\begin{document}
\begin{tikzpicture}
\begin{axis}%
[
grid=major,
xmin=-6,
xmax=6,
axis x line=bottom,
ytick={0,.5,1},
ymax=1,
axis y line=middle,
]
[
blue,%
mark=none,
samples=100,
domain=-6:6,
]
(x,{1/(1+exp(-x))});
\end{axis}
\end{tikzpicture}
\end{document}

-

pgfplots is already taken. Hence this is just a drawing using tikz as part of getting bored and had some time package (\usepackage[bored]{freetime}) :-). It is not up to scale.

\documentclass{standalone}
\usepackage{tikz}
%\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[y=10cm]
\tikzset{help lines/.style={color=blue!50}}
\draw[step=1cm,help lines] (-6,0) grid (6,1);
\draw[ultra thin,step=.5cm,help lines] (-6,0) grid (6,1);
\foreach \x in {-6,-5,...,6}{
\draw[y=1cm,thick,blue] (\x,0) -- (\x,-0.2);
\node[y=1cm] at (\x,-0.4) {\x};
}
\foreach \y in {0.5,1}{
\draw[thick,blue] (0,\y) -- (-0.2,\y);
\node at (-0.45,\y) {\y};
}
\coordinate (a) at (6,1);
\coordinate (b) at (-6,0);
\draw (b) edge[magenta,ultra thick,out=360,in=180,looseness = 1.7] (a);
\end{tikzpicture}
\end{document}


tikz also offers a plot facility, though it is not comparable with pgfplots. Following code is given just for illustration while it is always better to use pgfplots fot plots.

\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\draw[color=magenta] plot[
mark=none,
samples=100,
domain=-6:6,
] ({\x},{1/(1+exp(-\x))});;
\end{tikzpicture}
\end{document}

-