# Tikz picture + function plotting | what once worked, no longer does

For one of my classes, I use a fair number of function plots, which I generate using TikZ, and tikzpicture. Unfortunately, what once compiled fine (probably last fall when I last made significant changes), no longer does. I have gnuplot 4.6 installed, and I believe it is working (although given the problems I'm having, can't be sure).

Here is a MWE:

\documentclass{article}

\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{arrows,matrix,positioning}
\usepackage{pgfplots}

\pagestyle{empty}

\begin{document}

Here is a figure:

\begin{center}
\begin{tikzpicture}[x=0.075cm,y=0.0225cm]

% set up maximum and minimum x- and y-coordinates
\def\xmin{-0.5}
\def\xmax{150}
\def\ymin{-1.8}
\def\ymax{210}

\draw[->,thick] (\xmin,0) -- (\xmax,0) node[right] {time};
\draw[->,thick] (0,\ymin) -- (0,\ymax) node[above] {$N$};

% tick marks and tick labels on axes
\foreach \x in {0,20,40,...,140}
\draw[thick] (\x,0pt) -- (\x,-3pt)
node[anchor=north] {\footnotesize\x};
\foreach \y in {0,25,50,...,200}
\draw[thick] (0pt,\y) -- (-3pt,\y)
node[anchor=east] {\footnotesize\y};

% now plot the function
\draw[color=black,thick, smooth,domain=0:148.1] plot[id=sigmoid] function{5.12821*2.71828**(0.1*x)/(1+(5.12821/200)*2.71828**(0.1*x))};

\end{tikzpicture}
\end{center}

\end{document}


When I try to compile this (MikTeX 29, Windows 7), the axes are plotted as they should be, but not the function itself (which is disappointing, since plotting the function is the point of the exercise).

Can someone do a test compile of the MWE at their end? If you can get it to compile, and generate the function plot, then the problem is likely with my gnuplot install. If you can't get it to compile, then something in TikZ has changed that bricks the MWE code.

Thanks very much in advance.

• Works on my computer without any issues. But did you consider using pgfplots? – percusse Feb 11 '15 at 15:10
• Here is the same exercise \begin{tikzpicture} \begin{axis}[xmin=0.5,xmax=150,ymin=-1.8,ymax=210, xlabel=time,ylabel=$N$,axis lines=middle, width=8cm,height=5cm]\addplot[thick,domain=0:148.1]{5.12821*(2.71828)^(0.1*x)/(1+(5.12821/200)*(2.71828)^(0.1*x))};\end{axis}\end{tikzpicture} – percusse Feb 11 '15 at 15:12
• Works here as well. Distribution: MacTeX (TeX Live 2014), on Mac OS X 8 (Mountain Lion). – Franck Pastor Feb 11 '15 at 15:34

## 1 Answer

Thanks to those who tried the MWE at their end -- the fact that you got things to compile correctly was the confirmation I needed that the problem was 'at my end'. gnuplot (5.0) is installed correctly on my machine, and the executable(s) are in the env path, so not gnuplot. But, then I remembered that I'm running gnuplot external to*TeX, and need to escape things. So, I fed --enable-write18 to MikTeX in various places, and, MWE compiles fine.

As for the pgfplots suggestion from @percusse, my files are a hodegepodge of different graphics tools (PStricks here, gnuplot there, some pgf plots over yonder...), reflecting the evolution in my understanding and skill with different graphics tools that are out there for *TeX. For this particular project (a book, actually), I'd used the tikz/gnuplot approach, and was (and am) loathe to redo all of the figures to pgfplots format. Noty because of an inherenet preference for one over the other, but because..I'm lazy. ;-)

Thanks again...

• pgfplots is based on tikz so it doesn't bring any complication. The rest can stay as is. – percusse Feb 11 '15 at 17:45
• I seem to recall differences in how ticks and tick labels are handled, but I'll confess, its been a while. – Johnny Canuck Feb 11 '15 at 21:19