[Tex/LaTex] GNUPLOT and cumulative distribution function (CDF) issues

distributionsgnuplotpgfplots

I have several issues that I can not resolve on my own.

  1. The label of the y-axis can not displayed on the top / above the arrow
  2. Then I can not put the 1/100% of the CDF on the y-axis (not even manually) – the "1" disappears.
  3. Furthermore the CDF has a long tail on the left side – but the graph suddenly stops.
  4. There is an "1" at the upper right corner and it does not disappear by using \pagestyle{empty}

% gnuplot is needed: https://sourceforge.net/projects/gnuplot/files/gnuplot/

% enter "PATH": c:\programme\gnuplot\bin

% pdfLaTeX: pdflatex -synctex=1 -interaction=nonstopmode -enable-write18 %.tex

The code

\documentclass{minimal}
\usepackage[language=autobib,backend=biber]{biblatex}
\pagestyle{empty} %There is a "1" in the upper right corner! - why?
\usepackage{amsmath}

\usepackage{pgfplots}
\pgfplotsset{compat=1.8}
\usepgfplotslibrary{fillbetween}
\pgfdeclarelayer{pre main}
\pgfsetlayers{pre main,main}

\usepackage{scrlayer-scrpage}
\usepackage{pdflscape}


\usepackage[default]{sourcesanspro}


\def\cdf(#1)(#2)(#3){0.5*(1+(erf((#1-#2)/(#3*sqrt(2)))))}
\def\cdfx(#1)(#2)(#3){0.5*(1+(erf((#1-#2)/(#3*sqrt(2)))))}

\DeclareMathOperator{\CDF}{cdf}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
      width=12cm,height=12cm,
      ymin=0,ymax=1.1,
      %xmin=-5.1, %Please turn on to see the "missing tail"!
      xmax=6,
      axis x line=center,
      axis y line=left,
      xlabel={$x$},
      xtick=\empty,
      xlabel style={right},
      ytick=\empty,
      ylabel={$F(x)$, $G(x)$},
      ylabel style={above}, %Why is this not working? Label still "left"
      smooth,
      no markers,
      clip=false
      ]


\addplot[smooth,black,name path=A, tick] gnuplot{\cdf(x)(0)(1)} node[right,pos=0.5, xshift=2ex]{$F$} node[right,pos=0.5, xshift=-12ex, yshift=0.75ex]{$G$};
\addplot[smooth,black,densely dashed,name path=B,tick]gnuplot{\cdfx(x+0.5)(0)(0,2)};
% Why is the tail on the left side of the graph missing?!

\pgfonlayer{pre main}
\tikzfillbetween[of=A and B, split, every even segment/.style={black}]{black!35};
\endpgfonlayer


\draw [black,densely dotted](0,100)--(1000,100)--(1000,0);  

\node at (1050,100){$1$}; % \node at (-10,100){$1$} Does not work - "1" disapears! 


\end{axis}
\end{tikzpicture}
\end{document}

Best Answer

I admit I cannot explain logically the y label style thing, but here you are:

\documentclass{standalone}
\usepackage{amsmath}

\usepackage{pgfplots}
\pgfplotsset{compat=1.8}
\usepgfplotslibrary{fillbetween}
\pgfdeclarelayer{pre main}
\pgfsetlayers{pre main,main}


\usepackage[default]{sourcesanspro}


\def\cdf(#1)(#2)(#3){0.5*(1+(erf((#1-#2)/(#3*sqrt(2)))))}
\def\cdfx(#1)(#2)(#3){0.5*(1+(erf((#1-#2)/(#3*sqrt(2)))))}

\DeclareMathOperator{\CDF}{cdf}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
      width=12cm,height=12cm,
      ymin=0,ymax=1.1,
      xmin=-6, %changed
      xmax=6,
      domain=-6:6, % added 
      axis x line=center,
      axis y line=left,
      xlabel={$x$},
      xtick = \empty,
      xlabel style={right},
      ytick={0.01, 1.0},                  % added
      yticklabels={$1$\%, $100$\%,},      % added 
      %% changed, undoing the changes by axis y line = left
      y label style={rotate=-90,at={(axis description cs:0,1)}, above }, 
      ylabel={$F(x)$, $G(x)$},
      smooth,
      no markers,
      clip=false
      ]


    \addplot[smooth,black,name path=A, tick] gnuplot{\cdf(x)(0)(1)} node[right,pos=0.5, xshift=2ex]{$F$} node[right,pos=0.5, xshift=-12ex, yshift=0.75ex]{$G$};
    \addplot[smooth,black,densely dashed,name path=B,tick]gnuplot{\cdfx(x+0.5)(0)(0,2)};

    \pgfonlayer{pre main}
    \tikzfillbetween[of=A and B, split, every even segment/.style={black}]{black!35};
    \endpgfonlayer


% using axis cs: here. Default for pgfplots >= 1.11 
\draw [black,densely dotted](axis cs: -6,1)--(axis cs:5,1)--(axis cs:5,0);  

% no idea which coords are these...  
%\node at (axis cs:1050,100){$1$}; % \node at (-10,100){$1$}  


\end{axis}
\end{tikzpicture}
\end{document}

...with explications in the comments. Notice that I have removed all the packages that were not significant for the graph.

enter image description here