I am using the following code, which is supposed to cut a function in N parts :
\documentclass[11pt]{article}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\resizebox{\columnwidth}{!}{%
\begin{tikzpicture}
\begin{axis}
[
grid,
anchor=origin,
%axis equal=false,
xmin=0, xmax=1,
ymin=0, ymax=10,
minor tick num=1,
axis lines = middle,
tick label style={inner sep=2pt, font=\footnotesize},
%
every axis plot post/.append style={thick},
samples=500
]
\addplot [domain=0:1, color=blue] {-2*ln(x)};
\end{axis}
% Add lines
\pgfmathsetmacro{\N}{4};
\foreach \x in {\N,...,0} {
\draw [line width=0.15mm, red] (\x/\N, 0) -- (\x/\N, 10);
}
\end{tikzpicture}
}
\end{document}
But, instead of having 5 lines cutting my function from 0 to 1, this is what I have :
Do you have any idea of why this issue appears ?
P.S : Do you have a better way to declare variables than \pgfmathsetmacro ?

