## LaTeX forum ⇒ Graphics, Figures & Tables ⇒ 3D tikz problem

Information and discussion about graphics, figures & tables in LaTeX documents.
layuval
Posts: 19
Joined: Thu Aug 18, 2016 11:37 pm

### 3D tikz problem

Hello everyone,
I have some problem with outcome I get when running 3d on tikz.
I need to produce two 3D graphs but in one of then I'm not getting the desired outcome.

I have attached 3 files, the desired equation, my commands and how the graph should look like.

Thank you for the help.
Attachments
Actual graph
Screen Shot 2016-08-18 at 10.17.21 PM.png (80.22 KiB) Viewed 3377 times
Try 3.tex
Commends
Desired equation
Equation.png (18.58 KiB) Viewed 3377 times

Tags:

Stefan Kottwitz
Posts: 9501
Joined: Mon Mar 10, 2008 9:44 pm
This comes a bit closer. Still, your sample graph seems to treat large values in a certain way, such as cutting off, while pgfplots discards or jumps. I guess this can be solved, I just don't see a way right now.

\documentclass[border=10pt]{standalone}\usepackage{pgfplots}\pgfplotsset{width=7cm,compat=1.8}\usepgfplotslibrary{colormaps}\begin{document}\begin{tikzpicture}           \begin{axis}[zmin=0,zmax=10000]           \addplot3[surf,colormap/autumn,samples=50,samples y=30,                     domain=0.0001:0.9999,restrict z to domain={0:20000},                     unbounded coords=jump]              {((256*y^2*(1-x)^2)/(x^2*(1-sqrt(x/(2-x)))^4))*(1-(((12-3*x)*(1-x))/(4*(2-x)^2))-((1-sqrt(x/(2-x)))^2/16))};           \end{axis}       \end{tikzpicture}\end{document}

Stefan

layuval
Posts: 19
Joined: Thu Aug 18, 2016 11:37 pm
Hi Stafen,
Thanks for the help that is much better than what I got.
Any ideas how I can add counter lines?

Stefan Kottwitz
Posts: 9501
Joined: Mon Mar 10, 2008 9:44 pm
layuval wrote:Any ideas how I can add counter lines?

Hm, do you mean contour lines? pgfplots can do it, using gnuplot in the background. Take a look at the pgfplots manual, 4.6.8 Contour Plots.

Stefan

Stefan Kottwitz
Posts: 9501
Joined: Mon Mar 10, 2008 9:44 pm
Here is another version. I restricted z using domain* to get this top surface.

A second plot is just a try to visualize horizontal lines a bit stronger, you could omit it.

\documentclass[border=10pt]{standalone}\usepackage{pgfplots}\pgfplotsset{width=7cm,compat=1.8}\usepgfplotslibrary{colormaps}\begin{document}\begin{tikzpicture}   \begin{axis}[       zmin=0,zmax=11000,       scaled z ticks=false,       tick label style={font=\scriptsize},     ]     \addplot3[surf,shader=faceted interp,               colormap/autumn,               samples=40,samples y=40,               domain=0.0001:0.9999,               restrict z to domain*={0:10000},               unbounded coords=jump,              ]      {((256*y^2*(1-x)^2)/(x^2*(1-sqrt(x/(2-x)))^4))       *(1-(((12-3*x)*(1-x))/(4*(2-x)^2))       -((1-sqrt(x/(2-x)))^2/16))};     \addplot3[z filter/.expression={z>=10000 ? nan : z},               colormap/autumn,               fill=none,               smooth,               samples=40,samples y=40,               domain=0.0001:0.9999,               unbounded coords=jump,              ]      {((256*y^2*(1-x)^2)/(x^2*(1-sqrt(x/(2-x)))^4))       *(1-(((12-3*x)*(1-x))/(4*(2-x)^2))       -((1-sqrt(x/(2-x)))^2/16))};   \end{axis}\end{tikzpicture}\end{document}

plot.png (115.8 KiB) Viewed 3341 times

Stefan

layuval
Posts: 19
Joined: Thu Aug 18, 2016 11:37 pm
Thanks again!
Is there any guideline I can follow when producing this kind of graph?
I'm asking since I have similar problem with another graph.
As can be seen in the attached file the graph looks perfect when bounded in 0.1 but very unclear with any higher value.
Attachments
f&z impact on alfa.tex

Stefan Kottwitz
Posts: 9501
Joined: Mon Mar 10, 2008 9:44 pm
There's no guideline. Though there are some good ways to fix things, such as restricting a domain, treating unbound coordinates (jump or discard), filters for results, point meta settings. They are in the pgfplots manual, may be hard to find as it's a comprehensive reference. I like this big documentation with many examples though.

I made a gallery for getting started or for getting ideas: pgfplots.net.

I must admit that it took me some time to fine-tune your plot. It's often experimenting with settings and choosing the best. Btw. one nice trick I remember is changing parametrization for a better plot, as here: Cutting plots. There I also added a contour plot for the cut. I like plotting as the plots on tikz.de show.

Stefan