Declare function for tikzpicture












6















I'd like to declare a function that will be part of the equation that I then want to plot. The equation that I want to plot is defined as



frac{e^{-rT}N'(d_{2})}{Ssigmasqrt{T}}


The function to be declared is the probability density function



N'left (x  right )=frac{1}{sqrt{2pi}}e^{-x^2/2}


where x should equal to d_2, and d_2 must also be declared by



d_{2}=frac{ln(S/K)+(r-frac{sigma^2}{2})T}{sigmasqrt{T}})


If possible I'd like to be able to define K, r and sigma in advance, so that they can flow into above calculation as fixed values. For the values of S (x axis) and T (y axis) I want to take a different domains, e.g. for S a range 95 to 105, and for T a range 0.01 to 0.3. The overall result should be a surfaceplot where the results of the intial equation are on the z axis. Thanks a million, I hope so much that somebody can help me!



ADDITION: the code that was provided by @percusse works very well but when I try to modify it following the logic of its structure I get an error. Here is the modified code:



documentclass{article}
usepackage{pgfplots}
begin{document}

begin{tikzpicture}[
declare function={ Nprime(x) = 1/(sqrt(2*pi))*exp(-0.5*(pow(x,2)));
d1(x,y,KK,RR,SIG) = (ln(x/KK)+(RR+(pow(SIG,2)/2)*y))/(SIG*(sqrt(y)));
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)*d1*Nprime(d2(x,y,KK,RR,SIG))/(y*(pow(x,2))*(pow(SIG,2))));
},
]
begin{axis}[ y domain=0.01:0.3, domain=95:105,view={25}{20},
]
addplot3[surf] {myfun(x,y,100,0,0.09)};
end{axis}
end{tikzpicture}
end{document}


What am I doing wrong?



ONE MORE ADDITION: I have tried to swap the y and SIG values. Here is the code that does not work



documentclass{article}
usepackage{pgfplots}
begin{document}
begin{tikzpicture}[
declare function={ Nprime(x) = 1/(sqrt(2*pi))*exp(-0.5*(pow(x,2)));
d2(x,SIG,KK,RR,y) = (ln(x/KK)+(RR-(pow(SIG,2)/2)*y))/(SIG*(sqrt(y)));
myfun(x,SIG,KK,RR,y) = exp(-RR*y)*Nprime(d2(x,SIG,KK,RR,y))/(x*SIG*sqrt(y));
},
]
begin{axis}[
y domain=0.01:0.09, domain=95:105, view={25}{20},
]
addplot3[surf] {myfun(x,SIG,100,0,0.04)};
end{axis}
end{tikzpicture}
end{document}


What's wrong with it? Thanks a lot!










share|improve this question




















  • 1





    I fear that your aim is definitely not possible : in general the elaborate LaTeX formulas cannot be parsed by the pgf engine. Just as an example, there is not frac and your denominator would be writen as S*sig*sqrt(T) provided that you have def-ined the values of S,sig and T (note te absence of before sqrt to {evaluate} de square root !

    – Jhor
    Jul 21 '13 at 11:17













  • can you provide some values of the constants?

    – percusse
    Jul 21 '13 at 11:28











  • K = 100, r = 0, sigma = 0.09

    – ajafarov
    Jul 21 '13 at 11:29











  • the thing is, that I have that graph in matlab and I've tried to use matlab2tikz to transform the matlab-figure to latex. matlab2tikz does it with some distrotion, i.e. it simply chops off a part of the graph and places that piece arbitrarily somewhere else

    – ajafarov
    Jul 21 '13 at 11:35











  • @ajafarov You are missing the arguments of d1

    – percusse
    Jul 21 '13 at 14:36
















6















I'd like to declare a function that will be part of the equation that I then want to plot. The equation that I want to plot is defined as



frac{e^{-rT}N'(d_{2})}{Ssigmasqrt{T}}


The function to be declared is the probability density function



N'left (x  right )=frac{1}{sqrt{2pi}}e^{-x^2/2}


where x should equal to d_2, and d_2 must also be declared by



d_{2}=frac{ln(S/K)+(r-frac{sigma^2}{2})T}{sigmasqrt{T}})


If possible I'd like to be able to define K, r and sigma in advance, so that they can flow into above calculation as fixed values. For the values of S (x axis) and T (y axis) I want to take a different domains, e.g. for S a range 95 to 105, and for T a range 0.01 to 0.3. The overall result should be a surfaceplot where the results of the intial equation are on the z axis. Thanks a million, I hope so much that somebody can help me!



ADDITION: the code that was provided by @percusse works very well but when I try to modify it following the logic of its structure I get an error. Here is the modified code:



documentclass{article}
usepackage{pgfplots}
begin{document}

begin{tikzpicture}[
declare function={ Nprime(x) = 1/(sqrt(2*pi))*exp(-0.5*(pow(x,2)));
d1(x,y,KK,RR,SIG) = (ln(x/KK)+(RR+(pow(SIG,2)/2)*y))/(SIG*(sqrt(y)));
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)*d1*Nprime(d2(x,y,KK,RR,SIG))/(y*(pow(x,2))*(pow(SIG,2))));
},
]
begin{axis}[ y domain=0.01:0.3, domain=95:105,view={25}{20},
]
addplot3[surf] {myfun(x,y,100,0,0.09)};
end{axis}
end{tikzpicture}
end{document}


What am I doing wrong?



ONE MORE ADDITION: I have tried to swap the y and SIG values. Here is the code that does not work



documentclass{article}
usepackage{pgfplots}
begin{document}
begin{tikzpicture}[
declare function={ Nprime(x) = 1/(sqrt(2*pi))*exp(-0.5*(pow(x,2)));
d2(x,SIG,KK,RR,y) = (ln(x/KK)+(RR-(pow(SIG,2)/2)*y))/(SIG*(sqrt(y)));
myfun(x,SIG,KK,RR,y) = exp(-RR*y)*Nprime(d2(x,SIG,KK,RR,y))/(x*SIG*sqrt(y));
},
]
begin{axis}[
y domain=0.01:0.09, domain=95:105, view={25}{20},
]
addplot3[surf] {myfun(x,SIG,100,0,0.04)};
end{axis}
end{tikzpicture}
end{document}


What's wrong with it? Thanks a lot!










share|improve this question




















  • 1





    I fear that your aim is definitely not possible : in general the elaborate LaTeX formulas cannot be parsed by the pgf engine. Just as an example, there is not frac and your denominator would be writen as S*sig*sqrt(T) provided that you have def-ined the values of S,sig and T (note te absence of before sqrt to {evaluate} de square root !

    – Jhor
    Jul 21 '13 at 11:17













  • can you provide some values of the constants?

    – percusse
    Jul 21 '13 at 11:28











  • K = 100, r = 0, sigma = 0.09

    – ajafarov
    Jul 21 '13 at 11:29











  • the thing is, that I have that graph in matlab and I've tried to use matlab2tikz to transform the matlab-figure to latex. matlab2tikz does it with some distrotion, i.e. it simply chops off a part of the graph and places that piece arbitrarily somewhere else

    – ajafarov
    Jul 21 '13 at 11:35











  • @ajafarov You are missing the arguments of d1

    – percusse
    Jul 21 '13 at 14:36














6












6








6


3






I'd like to declare a function that will be part of the equation that I then want to plot. The equation that I want to plot is defined as



frac{e^{-rT}N'(d_{2})}{Ssigmasqrt{T}}


The function to be declared is the probability density function



N'left (x  right )=frac{1}{sqrt{2pi}}e^{-x^2/2}


where x should equal to d_2, and d_2 must also be declared by



d_{2}=frac{ln(S/K)+(r-frac{sigma^2}{2})T}{sigmasqrt{T}})


If possible I'd like to be able to define K, r and sigma in advance, so that they can flow into above calculation as fixed values. For the values of S (x axis) and T (y axis) I want to take a different domains, e.g. for S a range 95 to 105, and for T a range 0.01 to 0.3. The overall result should be a surfaceplot where the results of the intial equation are on the z axis. Thanks a million, I hope so much that somebody can help me!



ADDITION: the code that was provided by @percusse works very well but when I try to modify it following the logic of its structure I get an error. Here is the modified code:



documentclass{article}
usepackage{pgfplots}
begin{document}

begin{tikzpicture}[
declare function={ Nprime(x) = 1/(sqrt(2*pi))*exp(-0.5*(pow(x,2)));
d1(x,y,KK,RR,SIG) = (ln(x/KK)+(RR+(pow(SIG,2)/2)*y))/(SIG*(sqrt(y)));
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)*d1*Nprime(d2(x,y,KK,RR,SIG))/(y*(pow(x,2))*(pow(SIG,2))));
},
]
begin{axis}[ y domain=0.01:0.3, domain=95:105,view={25}{20},
]
addplot3[surf] {myfun(x,y,100,0,0.09)};
end{axis}
end{tikzpicture}
end{document}


What am I doing wrong?



ONE MORE ADDITION: I have tried to swap the y and SIG values. Here is the code that does not work



documentclass{article}
usepackage{pgfplots}
begin{document}
begin{tikzpicture}[
declare function={ Nprime(x) = 1/(sqrt(2*pi))*exp(-0.5*(pow(x,2)));
d2(x,SIG,KK,RR,y) = (ln(x/KK)+(RR-(pow(SIG,2)/2)*y))/(SIG*(sqrt(y)));
myfun(x,SIG,KK,RR,y) = exp(-RR*y)*Nprime(d2(x,SIG,KK,RR,y))/(x*SIG*sqrt(y));
},
]
begin{axis}[
y domain=0.01:0.09, domain=95:105, view={25}{20},
]
addplot3[surf] {myfun(x,SIG,100,0,0.04)};
end{axis}
end{tikzpicture}
end{document}


What's wrong with it? Thanks a lot!










share|improve this question
















I'd like to declare a function that will be part of the equation that I then want to plot. The equation that I want to plot is defined as



frac{e^{-rT}N'(d_{2})}{Ssigmasqrt{T}}


The function to be declared is the probability density function



N'left (x  right )=frac{1}{sqrt{2pi}}e^{-x^2/2}


where x should equal to d_2, and d_2 must also be declared by



d_{2}=frac{ln(S/K)+(r-frac{sigma^2}{2})T}{sigmasqrt{T}})


If possible I'd like to be able to define K, r and sigma in advance, so that they can flow into above calculation as fixed values. For the values of S (x axis) and T (y axis) I want to take a different domains, e.g. for S a range 95 to 105, and for T a range 0.01 to 0.3. The overall result should be a surfaceplot where the results of the intial equation are on the z axis. Thanks a million, I hope so much that somebody can help me!



ADDITION: the code that was provided by @percusse works very well but when I try to modify it following the logic of its structure I get an error. Here is the modified code:



documentclass{article}
usepackage{pgfplots}
begin{document}

begin{tikzpicture}[
declare function={ Nprime(x) = 1/(sqrt(2*pi))*exp(-0.5*(pow(x,2)));
d1(x,y,KK,RR,SIG) = (ln(x/KK)+(RR+(pow(SIG,2)/2)*y))/(SIG*(sqrt(y)));
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)*d1*Nprime(d2(x,y,KK,RR,SIG))/(y*(pow(x,2))*(pow(SIG,2))));
},
]
begin{axis}[ y domain=0.01:0.3, domain=95:105,view={25}{20},
]
addplot3[surf] {myfun(x,y,100,0,0.09)};
end{axis}
end{tikzpicture}
end{document}


What am I doing wrong?



ONE MORE ADDITION: I have tried to swap the y and SIG values. Here is the code that does not work



documentclass{article}
usepackage{pgfplots}
begin{document}
begin{tikzpicture}[
declare function={ Nprime(x) = 1/(sqrt(2*pi))*exp(-0.5*(pow(x,2)));
d2(x,SIG,KK,RR,y) = (ln(x/KK)+(RR-(pow(SIG,2)/2)*y))/(SIG*(sqrt(y)));
myfun(x,SIG,KK,RR,y) = exp(-RR*y)*Nprime(d2(x,SIG,KK,RR,y))/(x*SIG*sqrt(y));
},
]
begin{axis}[
y domain=0.01:0.09, domain=95:105, view={25}{20},
]
addplot3[surf] {myfun(x,SIG,100,0,0.04)};
end{axis}
end{tikzpicture}
end{document}


What's wrong with it? Thanks a lot!







tikz-pgf pgfplots diagrams






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 22 '13 at 11:44







ajafarov

















asked Jul 21 '13 at 10:34









ajafarovajafarov

3571513




3571513








  • 1





    I fear that your aim is definitely not possible : in general the elaborate LaTeX formulas cannot be parsed by the pgf engine. Just as an example, there is not frac and your denominator would be writen as S*sig*sqrt(T) provided that you have def-ined the values of S,sig and T (note te absence of before sqrt to {evaluate} de square root !

    – Jhor
    Jul 21 '13 at 11:17













  • can you provide some values of the constants?

    – percusse
    Jul 21 '13 at 11:28











  • K = 100, r = 0, sigma = 0.09

    – ajafarov
    Jul 21 '13 at 11:29











  • the thing is, that I have that graph in matlab and I've tried to use matlab2tikz to transform the matlab-figure to latex. matlab2tikz does it with some distrotion, i.e. it simply chops off a part of the graph and places that piece arbitrarily somewhere else

    – ajafarov
    Jul 21 '13 at 11:35











  • @ajafarov You are missing the arguments of d1

    – percusse
    Jul 21 '13 at 14:36














  • 1





    I fear that your aim is definitely not possible : in general the elaborate LaTeX formulas cannot be parsed by the pgf engine. Just as an example, there is not frac and your denominator would be writen as S*sig*sqrt(T) provided that you have def-ined the values of S,sig and T (note te absence of before sqrt to {evaluate} de square root !

    – Jhor
    Jul 21 '13 at 11:17













  • can you provide some values of the constants?

    – percusse
    Jul 21 '13 at 11:28











  • K = 100, r = 0, sigma = 0.09

    – ajafarov
    Jul 21 '13 at 11:29











  • the thing is, that I have that graph in matlab and I've tried to use matlab2tikz to transform the matlab-figure to latex. matlab2tikz does it with some distrotion, i.e. it simply chops off a part of the graph and places that piece arbitrarily somewhere else

    – ajafarov
    Jul 21 '13 at 11:35











  • @ajafarov You are missing the arguments of d1

    – percusse
    Jul 21 '13 at 14:36








1




1





I fear that your aim is definitely not possible : in general the elaborate LaTeX formulas cannot be parsed by the pgf engine. Just as an example, there is not frac and your denominator would be writen as S*sig*sqrt(T) provided that you have def-ined the values of S,sig and T (note te absence of before sqrt to {evaluate} de square root !

– Jhor
Jul 21 '13 at 11:17







I fear that your aim is definitely not possible : in general the elaborate LaTeX formulas cannot be parsed by the pgf engine. Just as an example, there is not frac and your denominator would be writen as S*sig*sqrt(T) provided that you have def-ined the values of S,sig and T (note te absence of before sqrt to {evaluate} de square root !

– Jhor
Jul 21 '13 at 11:17















can you provide some values of the constants?

– percusse
Jul 21 '13 at 11:28





can you provide some values of the constants?

– percusse
Jul 21 '13 at 11:28













K = 100, r = 0, sigma = 0.09

– ajafarov
Jul 21 '13 at 11:29





K = 100, r = 0, sigma = 0.09

– ajafarov
Jul 21 '13 at 11:29













the thing is, that I have that graph in matlab and I've tried to use matlab2tikz to transform the matlab-figure to latex. matlab2tikz does it with some distrotion, i.e. it simply chops off a part of the graph and places that piece arbitrarily somewhere else

– ajafarov
Jul 21 '13 at 11:35





the thing is, that I have that graph in matlab and I've tried to use matlab2tikz to transform the matlab-figure to latex. matlab2tikz does it with some distrotion, i.e. it simply chops off a part of the graph and places that piece arbitrarily somewhere else

– ajafarov
Jul 21 '13 at 11:35













@ajafarov You are missing the arguments of d1

– percusse
Jul 21 '13 at 14:36





@ajafarov You are missing the arguments of d1

– percusse
Jul 21 '13 at 14:36










1 Answer
1






active

oldest

votes


















13














I don't know what it should look like but from the constants you have provided I get this



documentclass{article}
usepackage{pgfplots}
begin{document}

begin{tikzpicture}[
declare function={ Nprime(x) = 1/(sqrt(2*pi))*exp(-0.5*(pow(x,2)));
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)*Nprime(d2(x,y,KK,RR,SIG))/(x*SIG*sqrt(y));
},
]
begin{axis}[y domain=0.01:0.3,domain=95:105,view={150}{20}]
addplot3[surf] {myfun(x,y,100,0,0.09)};
end{axis}
end{tikzpicture}


end{document}


enter image description here






share|improve this answer
























  • OH LA LAAAAA that is exactly what I need! You guys are simply Latex-Gods!!! Is it possible to replace the axis in the sense, that I get the 0-0.3 domain on the right hand side, and the 96-104 at the left hand side, simply replace them?

    – ajafarov
    Jul 21 '13 at 11:41











  • @ajafarov You can rotate the 3D view angles with view option added to the axis options. Replace it with view={25}{20}.

    – percusse
    Jul 21 '13 at 11:43











  • @ajafarov My pleasure. Next time please provide some more data and a MWE if possible. Writing the code from scratch is really not fun.

    – percusse
    Jul 21 '13 at 11:46











  • I will, thank you very very much!!!!

    – ajafarov
    Jul 21 '13 at 11:57











  • when I try to slightly modify the code that you have written today in order to make it suitable for another application I get an error: PGF Math: Could not parse input '' as a floating point number, sorry. The unreadable part was near..." could you please help me? why is it the case?

    – ajafarov
    Jul 21 '13 at 14:07











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f124878%2fdeclare-function-for-tikzpicture%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









13














I don't know what it should look like but from the constants you have provided I get this



documentclass{article}
usepackage{pgfplots}
begin{document}

begin{tikzpicture}[
declare function={ Nprime(x) = 1/(sqrt(2*pi))*exp(-0.5*(pow(x,2)));
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)*Nprime(d2(x,y,KK,RR,SIG))/(x*SIG*sqrt(y));
},
]
begin{axis}[y domain=0.01:0.3,domain=95:105,view={150}{20}]
addplot3[surf] {myfun(x,y,100,0,0.09)};
end{axis}
end{tikzpicture}


end{document}


enter image description here






share|improve this answer
























  • OH LA LAAAAA that is exactly what I need! You guys are simply Latex-Gods!!! Is it possible to replace the axis in the sense, that I get the 0-0.3 domain on the right hand side, and the 96-104 at the left hand side, simply replace them?

    – ajafarov
    Jul 21 '13 at 11:41











  • @ajafarov You can rotate the 3D view angles with view option added to the axis options. Replace it with view={25}{20}.

    – percusse
    Jul 21 '13 at 11:43











  • @ajafarov My pleasure. Next time please provide some more data and a MWE if possible. Writing the code from scratch is really not fun.

    – percusse
    Jul 21 '13 at 11:46











  • I will, thank you very very much!!!!

    – ajafarov
    Jul 21 '13 at 11:57











  • when I try to slightly modify the code that you have written today in order to make it suitable for another application I get an error: PGF Math: Could not parse input '' as a floating point number, sorry. The unreadable part was near..." could you please help me? why is it the case?

    – ajafarov
    Jul 21 '13 at 14:07
















13














I don't know what it should look like but from the constants you have provided I get this



documentclass{article}
usepackage{pgfplots}
begin{document}

begin{tikzpicture}[
declare function={ Nprime(x) = 1/(sqrt(2*pi))*exp(-0.5*(pow(x,2)));
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)*Nprime(d2(x,y,KK,RR,SIG))/(x*SIG*sqrt(y));
},
]
begin{axis}[y domain=0.01:0.3,domain=95:105,view={150}{20}]
addplot3[surf] {myfun(x,y,100,0,0.09)};
end{axis}
end{tikzpicture}


end{document}


enter image description here






share|improve this answer
























  • OH LA LAAAAA that is exactly what I need! You guys are simply Latex-Gods!!! Is it possible to replace the axis in the sense, that I get the 0-0.3 domain on the right hand side, and the 96-104 at the left hand side, simply replace them?

    – ajafarov
    Jul 21 '13 at 11:41











  • @ajafarov You can rotate the 3D view angles with view option added to the axis options. Replace it with view={25}{20}.

    – percusse
    Jul 21 '13 at 11:43











  • @ajafarov My pleasure. Next time please provide some more data and a MWE if possible. Writing the code from scratch is really not fun.

    – percusse
    Jul 21 '13 at 11:46











  • I will, thank you very very much!!!!

    – ajafarov
    Jul 21 '13 at 11:57











  • when I try to slightly modify the code that you have written today in order to make it suitable for another application I get an error: PGF Math: Could not parse input '' as a floating point number, sorry. The unreadable part was near..." could you please help me? why is it the case?

    – ajafarov
    Jul 21 '13 at 14:07














13












13








13







I don't know what it should look like but from the constants you have provided I get this



documentclass{article}
usepackage{pgfplots}
begin{document}

begin{tikzpicture}[
declare function={ Nprime(x) = 1/(sqrt(2*pi))*exp(-0.5*(pow(x,2)));
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)*Nprime(d2(x,y,KK,RR,SIG))/(x*SIG*sqrt(y));
},
]
begin{axis}[y domain=0.01:0.3,domain=95:105,view={150}{20}]
addplot3[surf] {myfun(x,y,100,0,0.09)};
end{axis}
end{tikzpicture}


end{document}


enter image description here






share|improve this answer













I don't know what it should look like but from the constants you have provided I get this



documentclass{article}
usepackage{pgfplots}
begin{document}

begin{tikzpicture}[
declare function={ Nprime(x) = 1/(sqrt(2*pi))*exp(-0.5*(pow(x,2)));
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)*Nprime(d2(x,y,KK,RR,SIG))/(x*SIG*sqrt(y));
},
]
begin{axis}[y domain=0.01:0.3,domain=95:105,view={150}{20}]
addplot3[surf] {myfun(x,y,100,0,0.09)};
end{axis}
end{tikzpicture}


end{document}


enter image description here







share|improve this answer












share|improve this answer



share|improve this answer










answered Jul 21 '13 at 11:36









percussepercusse

137k14254493




137k14254493













  • OH LA LAAAAA that is exactly what I need! You guys are simply Latex-Gods!!! Is it possible to replace the axis in the sense, that I get the 0-0.3 domain on the right hand side, and the 96-104 at the left hand side, simply replace them?

    – ajafarov
    Jul 21 '13 at 11:41











  • @ajafarov You can rotate the 3D view angles with view option added to the axis options. Replace it with view={25}{20}.

    – percusse
    Jul 21 '13 at 11:43











  • @ajafarov My pleasure. Next time please provide some more data and a MWE if possible. Writing the code from scratch is really not fun.

    – percusse
    Jul 21 '13 at 11:46











  • I will, thank you very very much!!!!

    – ajafarov
    Jul 21 '13 at 11:57











  • when I try to slightly modify the code that you have written today in order to make it suitable for another application I get an error: PGF Math: Could not parse input '' as a floating point number, sorry. The unreadable part was near..." could you please help me? why is it the case?

    – ajafarov
    Jul 21 '13 at 14:07



















  • OH LA LAAAAA that is exactly what I need! You guys are simply Latex-Gods!!! Is it possible to replace the axis in the sense, that I get the 0-0.3 domain on the right hand side, and the 96-104 at the left hand side, simply replace them?

    – ajafarov
    Jul 21 '13 at 11:41











  • @ajafarov You can rotate the 3D view angles with view option added to the axis options. Replace it with view={25}{20}.

    – percusse
    Jul 21 '13 at 11:43











  • @ajafarov My pleasure. Next time please provide some more data and a MWE if possible. Writing the code from scratch is really not fun.

    – percusse
    Jul 21 '13 at 11:46











  • I will, thank you very very much!!!!

    – ajafarov
    Jul 21 '13 at 11:57











  • when I try to slightly modify the code that you have written today in order to make it suitable for another application I get an error: PGF Math: Could not parse input '' as a floating point number, sorry. The unreadable part was near..." could you please help me? why is it the case?

    – ajafarov
    Jul 21 '13 at 14:07

















OH LA LAAAAA that is exactly what I need! You guys are simply Latex-Gods!!! Is it possible to replace the axis in the sense, that I get the 0-0.3 domain on the right hand side, and the 96-104 at the left hand side, simply replace them?

– ajafarov
Jul 21 '13 at 11:41





OH LA LAAAAA that is exactly what I need! You guys are simply Latex-Gods!!! Is it possible to replace the axis in the sense, that I get the 0-0.3 domain on the right hand side, and the 96-104 at the left hand side, simply replace them?

– ajafarov
Jul 21 '13 at 11:41













@ajafarov You can rotate the 3D view angles with view option added to the axis options. Replace it with view={25}{20}.

– percusse
Jul 21 '13 at 11:43





@ajafarov You can rotate the 3D view angles with view option added to the axis options. Replace it with view={25}{20}.

– percusse
Jul 21 '13 at 11:43













@ajafarov My pleasure. Next time please provide some more data and a MWE if possible. Writing the code from scratch is really not fun.

– percusse
Jul 21 '13 at 11:46





@ajafarov My pleasure. Next time please provide some more data and a MWE if possible. Writing the code from scratch is really not fun.

– percusse
Jul 21 '13 at 11:46













I will, thank you very very much!!!!

– ajafarov
Jul 21 '13 at 11:57





I will, thank you very very much!!!!

– ajafarov
Jul 21 '13 at 11:57













when I try to slightly modify the code that you have written today in order to make it suitable for another application I get an error: PGF Math: Could not parse input '' as a floating point number, sorry. The unreadable part was near..." could you please help me? why is it the case?

– ajafarov
Jul 21 '13 at 14:07





when I try to slightly modify the code that you have written today in order to make it suitable for another application I get an error: PGF Math: Could not parse input '' as a floating point number, sorry. The unreadable part was near..." could you please help me? why is it the case?

– ajafarov
Jul 21 '13 at 14:07


















draft saved

draft discarded




















































Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f124878%2fdeclare-function-for-tikzpicture%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

ComboBox Display Member on multiple fields

Is it possible to collect Nectar points via Trainline?