When I plot conditional functions with a domain gap in it the plot starts at the wrong point for the second range. It's easier when just looking at it:
The function definition for red should just print the upper part. I have no idea why it always starts at the base level where the first domain ended.
Does anybody know where this behavior comes from, why it doesn't happen with smaller numbers like shown with the green function and possibly how to fix it?
Code for the above example:
\documentclass[]{scrreprt}
\usepackage{pgfplots}
\begin{document}
\tikzset{declare function={
correct(\x)= (\x<=250000) * (100) +
and(\x>250000, \x<=500000) * (100 + \x / 1000);
}
}
\tikzset{declare function={
notCorrect(\x)= (\x<=1000000) * (0) +
and(\x>1000000, \x<=2000000) * (\x / 1000);
}
}
\begin{tikzpicture}
\begin{axis}
%correct
\addplot[
green,
domain=50000:250000
] {correct(x)};
\addplot[
green,
domain=250001:500000
] {correct(x)};
%not correct
\addplot[
red,
domain=1000:200000
] {notCorrect(x)};
\addplot[
red,
domain=1000001:1500000
] {notCorrect(x)};
\end{axis}
\end{tikzpicture}
\end{document}