TikZ PGF: How to draw 3D graph based on polynomial equation?












2















Unfortunately the TikZ-manual is a bit complicated to understand about this point.



Assumed we have some kind of squared 3D graph like this one:



Minimum Working Example (MWE):



documentclass{standalone}
usepackage{tikz, pgfplots}

begin{document}

begin{tikzpicture}
begin{axis}[samples=20]
addplot3[surf, domain=-2:2] {-x^2-y^2};
end{axis}
end{tikzpicture}

end{document}




Screenshot of the result:



Visualization of pipe flow






  1. How can I replace the current graph with some 4th degree polynomial formula in both directions x and y, e.g. x^4-2*x^2 and y^4-2*y^2

  2. How can I set the domain for x- and y-axis from -1 to +1 and the domain for z-axis from 0 to +1?




Just for explanation: The desired picture should visualize flow velocity distribution of pipe flow through porous media (where the flow velocity is highest at the border areas). While in empty pipe flow the velocity reaches its maximum in the center, this is different in porous media what I want to display with the graph.



Typical pipe flow (as 2D model):



Typical pipe flow



Typical pipe flow through porous media (as 2D model):



Flow through porous media



Please do not pay attention to the x- and y-shifts. The graph should be centered.










share|improve this question

























  • What precisely do you mean by "in both directions"? You can plot arbitrary functions with e.g. ` addplot3[surf, domain=-2:2] {x^4-2*x^2};.The domains can be set with domain=-1:1` and (if the y domain is different) domain y=-1:1.

    – marmot
    Jan 26 at 21:55


















2















Unfortunately the TikZ-manual is a bit complicated to understand about this point.



Assumed we have some kind of squared 3D graph like this one:



Minimum Working Example (MWE):



documentclass{standalone}
usepackage{tikz, pgfplots}

begin{document}

begin{tikzpicture}
begin{axis}[samples=20]
addplot3[surf, domain=-2:2] {-x^2-y^2};
end{axis}
end{tikzpicture}

end{document}




Screenshot of the result:



Visualization of pipe flow






  1. How can I replace the current graph with some 4th degree polynomial formula in both directions x and y, e.g. x^4-2*x^2 and y^4-2*y^2

  2. How can I set the domain for x- and y-axis from -1 to +1 and the domain for z-axis from 0 to +1?




Just for explanation: The desired picture should visualize flow velocity distribution of pipe flow through porous media (where the flow velocity is highest at the border areas). While in empty pipe flow the velocity reaches its maximum in the center, this is different in porous media what I want to display with the graph.



Typical pipe flow (as 2D model):



Typical pipe flow



Typical pipe flow through porous media (as 2D model):



Flow through porous media



Please do not pay attention to the x- and y-shifts. The graph should be centered.










share|improve this question

























  • What precisely do you mean by "in both directions"? You can plot arbitrary functions with e.g. ` addplot3[surf, domain=-2:2] {x^4-2*x^2};.The domains can be set with domain=-1:1` and (if the y domain is different) domain y=-1:1.

    – marmot
    Jan 26 at 21:55
















2












2








2


1






Unfortunately the TikZ-manual is a bit complicated to understand about this point.



Assumed we have some kind of squared 3D graph like this one:



Minimum Working Example (MWE):



documentclass{standalone}
usepackage{tikz, pgfplots}

begin{document}

begin{tikzpicture}
begin{axis}[samples=20]
addplot3[surf, domain=-2:2] {-x^2-y^2};
end{axis}
end{tikzpicture}

end{document}




Screenshot of the result:



Visualization of pipe flow






  1. How can I replace the current graph with some 4th degree polynomial formula in both directions x and y, e.g. x^4-2*x^2 and y^4-2*y^2

  2. How can I set the domain for x- and y-axis from -1 to +1 and the domain for z-axis from 0 to +1?




Just for explanation: The desired picture should visualize flow velocity distribution of pipe flow through porous media (where the flow velocity is highest at the border areas). While in empty pipe flow the velocity reaches its maximum in the center, this is different in porous media what I want to display with the graph.



Typical pipe flow (as 2D model):



Typical pipe flow



Typical pipe flow through porous media (as 2D model):



Flow through porous media



Please do not pay attention to the x- and y-shifts. The graph should be centered.










share|improve this question
















Unfortunately the TikZ-manual is a bit complicated to understand about this point.



Assumed we have some kind of squared 3D graph like this one:



Minimum Working Example (MWE):



documentclass{standalone}
usepackage{tikz, pgfplots}

begin{document}

begin{tikzpicture}
begin{axis}[samples=20]
addplot3[surf, domain=-2:2] {-x^2-y^2};
end{axis}
end{tikzpicture}

end{document}




Screenshot of the result:



Visualization of pipe flow






  1. How can I replace the current graph with some 4th degree polynomial formula in both directions x and y, e.g. x^4-2*x^2 and y^4-2*y^2

  2. How can I set the domain for x- and y-axis from -1 to +1 and the domain for z-axis from 0 to +1?




Just for explanation: The desired picture should visualize flow velocity distribution of pipe flow through porous media (where the flow velocity is highest at the border areas). While in empty pipe flow the velocity reaches its maximum in the center, this is different in porous media what I want to display with the graph.



Typical pipe flow (as 2D model):



Typical pipe flow



Typical pipe flow through porous media (as 2D model):



Flow through porous media



Please do not pay attention to the x- and y-shifts. The graph should be centered.







pgfplots 3d






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 27 at 12:10









Stefan Pinnow

19.7k83276




19.7k83276










asked Jan 26 at 21:49









DaveDave

818616




818616













  • What precisely do you mean by "in both directions"? You can plot arbitrary functions with e.g. ` addplot3[surf, domain=-2:2] {x^4-2*x^2};.The domains can be set with domain=-1:1` and (if the y domain is different) domain y=-1:1.

    – marmot
    Jan 26 at 21:55





















  • What precisely do you mean by "in both directions"? You can plot arbitrary functions with e.g. ` addplot3[surf, domain=-2:2] {x^4-2*x^2};.The domains can be set with domain=-1:1` and (if the y domain is different) domain y=-1:1.

    – marmot
    Jan 26 at 21:55



















What precisely do you mean by "in both directions"? You can plot arbitrary functions with e.g. ` addplot3[surf, domain=-2:2] {x^4-2*x^2};.The domains can be set with domain=-1:1` and (if the y domain is different) domain y=-1:1.

– marmot
Jan 26 at 21:55







What precisely do you mean by "in both directions"? You can plot arbitrary functions with e.g. ` addplot3[surf, domain=-2:2] {x^4-2*x^2};.The domains can be set with domain=-1:1` and (if the y domain is different) domain y=-1:1.

– marmot
Jan 26 at 21:55












1 Answer
1






active

oldest

votes


















5














A few things:




  1. The relevant manual here is probably the one of pgfplots, not TikZ.

  2. You can plot arbitrary functions.

  3. You are already setting a domain. If you want to have a different domain for y, use domain y=....

  4. You can add zmin and zmax to set the range of the z axis.


These things get illustrated in the MWE.



documentclass[tikz,border=3.14mm]{standalone}
usepackage{pgfplots}
pgfplotsset{compat=1.16}

begin{document}

begin{tikzpicture}
begin{axis}[samples=20,zmin=0,zmax=1]
addplot3[surf, domain=-1:1] {(x^4-2*x^2)*(y^4-2*y^2)};
end{axis}
end{tikzpicture}

end{document}


enter image description here



I do not quite understand what is meant by "in both directions", so I guessed what it might mean.






share|improve this answer
























  • I am very sorry for my bad explanation, so I've updated my question to clarify the desired sculpture. Thanks a lot for your help!

    – Dave
    Jan 27 at 9:58











  • Due to your great explanation, I will accept this as an answer but ask for a different shape in a further topic. I hope this is okay for you?

    – Dave
    Jan 27 at 11:12











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%2f472025%2ftikz-pgf-how-to-draw-3d-graph-based-on-polynomial-equation%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









5














A few things:




  1. The relevant manual here is probably the one of pgfplots, not TikZ.

  2. You can plot arbitrary functions.

  3. You are already setting a domain. If you want to have a different domain for y, use domain y=....

  4. You can add zmin and zmax to set the range of the z axis.


These things get illustrated in the MWE.



documentclass[tikz,border=3.14mm]{standalone}
usepackage{pgfplots}
pgfplotsset{compat=1.16}

begin{document}

begin{tikzpicture}
begin{axis}[samples=20,zmin=0,zmax=1]
addplot3[surf, domain=-1:1] {(x^4-2*x^2)*(y^4-2*y^2)};
end{axis}
end{tikzpicture}

end{document}


enter image description here



I do not quite understand what is meant by "in both directions", so I guessed what it might mean.






share|improve this answer
























  • I am very sorry for my bad explanation, so I've updated my question to clarify the desired sculpture. Thanks a lot for your help!

    – Dave
    Jan 27 at 9:58











  • Due to your great explanation, I will accept this as an answer but ask for a different shape in a further topic. I hope this is okay for you?

    – Dave
    Jan 27 at 11:12
















5














A few things:




  1. The relevant manual here is probably the one of pgfplots, not TikZ.

  2. You can plot arbitrary functions.

  3. You are already setting a domain. If you want to have a different domain for y, use domain y=....

  4. You can add zmin and zmax to set the range of the z axis.


These things get illustrated in the MWE.



documentclass[tikz,border=3.14mm]{standalone}
usepackage{pgfplots}
pgfplotsset{compat=1.16}

begin{document}

begin{tikzpicture}
begin{axis}[samples=20,zmin=0,zmax=1]
addplot3[surf, domain=-1:1] {(x^4-2*x^2)*(y^4-2*y^2)};
end{axis}
end{tikzpicture}

end{document}


enter image description here



I do not quite understand what is meant by "in both directions", so I guessed what it might mean.






share|improve this answer
























  • I am very sorry for my bad explanation, so I've updated my question to clarify the desired sculpture. Thanks a lot for your help!

    – Dave
    Jan 27 at 9:58











  • Due to your great explanation, I will accept this as an answer but ask for a different shape in a further topic. I hope this is okay for you?

    – Dave
    Jan 27 at 11:12














5












5








5







A few things:




  1. The relevant manual here is probably the one of pgfplots, not TikZ.

  2. You can plot arbitrary functions.

  3. You are already setting a domain. If you want to have a different domain for y, use domain y=....

  4. You can add zmin and zmax to set the range of the z axis.


These things get illustrated in the MWE.



documentclass[tikz,border=3.14mm]{standalone}
usepackage{pgfplots}
pgfplotsset{compat=1.16}

begin{document}

begin{tikzpicture}
begin{axis}[samples=20,zmin=0,zmax=1]
addplot3[surf, domain=-1:1] {(x^4-2*x^2)*(y^4-2*y^2)};
end{axis}
end{tikzpicture}

end{document}


enter image description here



I do not quite understand what is meant by "in both directions", so I guessed what it might mean.






share|improve this answer













A few things:




  1. The relevant manual here is probably the one of pgfplots, not TikZ.

  2. You can plot arbitrary functions.

  3. You are already setting a domain. If you want to have a different domain for y, use domain y=....

  4. You can add zmin and zmax to set the range of the z axis.


These things get illustrated in the MWE.



documentclass[tikz,border=3.14mm]{standalone}
usepackage{pgfplots}
pgfplotsset{compat=1.16}

begin{document}

begin{tikzpicture}
begin{axis}[samples=20,zmin=0,zmax=1]
addplot3[surf, domain=-1:1] {(x^4-2*x^2)*(y^4-2*y^2)};
end{axis}
end{tikzpicture}

end{document}


enter image description here



I do not quite understand what is meant by "in both directions", so I guessed what it might mean.







share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 26 at 22:04









marmotmarmot

97k4112213




97k4112213













  • I am very sorry for my bad explanation, so I've updated my question to clarify the desired sculpture. Thanks a lot for your help!

    – Dave
    Jan 27 at 9:58











  • Due to your great explanation, I will accept this as an answer but ask for a different shape in a further topic. I hope this is okay for you?

    – Dave
    Jan 27 at 11:12



















  • I am very sorry for my bad explanation, so I've updated my question to clarify the desired sculpture. Thanks a lot for your help!

    – Dave
    Jan 27 at 9:58











  • Due to your great explanation, I will accept this as an answer but ask for a different shape in a further topic. I hope this is okay for you?

    – Dave
    Jan 27 at 11:12

















I am very sorry for my bad explanation, so I've updated my question to clarify the desired sculpture. Thanks a lot for your help!

– Dave
Jan 27 at 9:58





I am very sorry for my bad explanation, so I've updated my question to clarify the desired sculpture. Thanks a lot for your help!

– Dave
Jan 27 at 9:58













Due to your great explanation, I will accept this as an answer but ask for a different shape in a further topic. I hope this is okay for you?

– Dave
Jan 27 at 11:12





Due to your great explanation, I will accept this as an answer but ask for a different shape in a further topic. I hope this is okay for you?

– Dave
Jan 27 at 11:12


















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%2f472025%2ftikz-pgf-how-to-draw-3d-graph-based-on-polynomial-equation%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?