LaTeX forum ⇒ Graphics, Figures & Tables3D 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

Postby layuval » Fri Aug 19, 2016 2:25 am

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
Screen Shot 2016-08-18 at 10.17.21 PM.png
Actual graph
Screen Shot 2016-08-18 at 10.17.21 PM.png (80.22 KiB) Viewed 3377 times
Try 3.tex
Commends
(405 Bytes) Downloaded 201 times
Equation.png
Desired equation
Equation.png (18.58 KiB) Viewed 3377 times

Tags:

User avatar
Stefan Kottwitz
Site Admin
Posts: 9501
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Fri Aug 19, 2016 6:25 am

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.

  1. \documentclass[border=10pt]{standalone}
  2. \usepackage{pgfplots}
  3. \pgfplotsset{width=7cm,compat=1.8}
  4. \usepgfplotslibrary{colormaps}
  5. \begin{document}
  6. \begin{tikzpicture}
  7. \begin{axis}[zmin=0,zmax=10000]
  8. \addplot3[surf,colormap/autumn,samples=50,samples y=30,
  9. domain=0.0001:0.9999,restrict z to domain={0:20000},
  10. unbounded coords=jump]
  11. {((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))};
  12. \end{axis}
  13. \end{tikzpicture}
  14. \end{document}


Stefan
Site admin

layuval
Posts: 19
Joined: Thu Aug 18, 2016 11:37 pm

Postby layuval » Fri Aug 19, 2016 7:27 am

Hi Stafen,
Thanks for the help that is much better than what I got.
Any ideas how I can add counter lines?

User avatar
Stefan Kottwitz
Site Admin
Posts: 9501
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Fri Aug 19, 2016 1:26 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
Site admin

User avatar
Stefan Kottwitz
Site Admin
Posts: 9501
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Fri Aug 19, 2016 2:34 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.

  1. \documentclass[border=10pt]{standalone}
  2. \usepackage{pgfplots}
  3. \pgfplotsset{width=7cm,compat=1.8}
  4. \usepgfplotslibrary{colormaps}
  5. \begin{document}
  6. \begin{tikzpicture}
  7. \begin{axis}[
  8. zmin=0,zmax=11000,
  9. scaled z ticks=false,
  10. tick label style={font=\scriptsize},
  11. ]
  12. \addplot3[surf,shader=faceted interp,
  13. colormap/autumn,
  14. samples=40,samples y=40,
  15. domain=0.0001:0.9999,
  16. restrict z to domain*={0:10000},
  17. unbounded coords=jump,
  18. ]
  19. {((256*y^2*(1-x)^2)/(x^2*(1-sqrt(x/(2-x)))^4))
  20. *(1-(((12-3*x)*(1-x))/(4*(2-x)^2))
  21. -((1-sqrt(x/(2-x)))^2/16))};
  22. \addplot3[z filter/.expression={z>=10000 ? nan : z},
  23. colormap/autumn,
  24. fill=none,
  25. smooth,
  26. samples=40,samples y=40,
  27. domain=0.0001:0.9999,
  28. unbounded coords=jump,
  29. ]
  30. {((256*y^2*(1-x)^2)/(x^2*(1-sqrt(x/(2-x)))^4))
  31. *(1-(((12-3*x)*(1-x))/(4*(2-x)^2))
  32. -((1-sqrt(x/(2-x)))^2/16))};
  33. \end{axis}
  34. \end{tikzpicture}
  35. \end{document}


plot.png
plot.png (115.8 KiB) Viewed 3341 times


Stefan
Site admin

layuval
Posts: 19
Joined: Thu Aug 18, 2016 11:37 pm

Postby layuval » Sun Aug 21, 2016 2:21 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
(569 Bytes) Downloaded 167 times

User avatar
Stefan Kottwitz
Site Admin
Posts: 9501
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Sun Aug 21, 2016 2:41 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
Site admin


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 10 guests