There are three issues in your code:
- Missing semicolon at the end of the definition of
myfun
. All functions defined using declare function
have to end with a semicolon.
- Typo in the function name (it's
normcdf
, not normdcf
).
- Incorrect call of the
normcdf
function. It takes three parameters: The x value, the mean, and the standard deviation of the normal distribution.
\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}[
declare function={ normcdf(\x,\m,\s) = 1/(1 + exp(-0.07056*((\x-\m)/\s)^3 - 1.5976*(\x-\m)/\s));
d2(\x,\y,\KK,\RR,\SIG) = (ln(\x/\KK)+(\RR-(pow(\SIG,2)/2)*\y))/(\SIG*(sqrt(\y)));
myfun(\x,\y,\KK,\RR,\SIG) = exp(-\RR*\y)*normcdf(d2(\x,\y,\KK,\RR,\SIG),0,1);
},
]
\begin{axis}[y domain=0.01:0.3,domain=95:105,view={210}{20}]
\addplot3[surf] {myfun(x,y,100,0,0.09)};
\end{axis}
\end{tikzpicture}
\end{document}
% arara: pdflatex
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{%
,compat=1.12
,every axis x label/.style={at={(current axis.right of origin)},anchor=north west}
,every axis y label/.style={at={(current axis.above origin)},anchor=north east}
}
\begin{document}
\begin{tikzpicture}
\begin{axis}[%
,xlabel=$e$
,ylabel=$F(e)$
,axis x line = bottom,axis y line = left
,ytick={0.25,0.5,...,1}
,ymax=1.2 % or enlarge y limits=upper
]
\addplot+[const plot, no marks, thick] coordinates {(0,0) (1,0.5) (2,0.75) (3,0.8) (4,1) (4.49,1)} node[above,pos=.57,black] {$F_x$};
\addplot+[const plot, no marks, thick] coordinates {(0,0) (1,0.25) (2,0.4) (3,0.5) (4,1) (4.49,1)} node[below=1.15cm,pos=.76,black] {$F_y$};
\end{axis}
\end{tikzpicture}
\end{document}
Jake has deleted his answer, but as there has been a slightly different approach, I add the information here:
You can add your data as:
\pgfplotstableread{
0 0 0
1 0.25 0.5
2 0.35 0.75
3 0.5 0.85
4 1 1
5 1 1
}\datatable
inside your tikzpicture
or in the preamble and read this out by:
\addplot+[thick, const plot mark left] table [x index=0, y index=1]{\datatable};
Best Answer
If anyone has interest, here is another solution with symbolic coordinates.