Graphics, Figures & Tables3D tikz problem

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

3D tikz problem

Post by layuval »

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

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

3D tikz problem

Post by Stefan Kottwitz »

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.

Code: Select all

\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
LaTeX.org admin
layuval
Posts: 19
Joined: Thu Aug 18, 2016 11:37 pm

Re: 3D tikz problem

Post by layuval »

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: 10324
Joined: Mon Mar 10, 2008 9:44 pm

3D tikz problem

Post by Stefan Kottwitz »

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
LaTeX.org admin
User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

3D tikz problem

Post by Stefan Kottwitz »

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.

Code: Select all

\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
plot.png (115.8 KiB) Viewed 6686 times
Stefan
LaTeX.org admin
layuval
Posts: 19
Joined: Thu Aug 18, 2016 11:37 pm

Re: 3D tikz problem

Post by layuval »

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 356 times
User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

3D tikz problem

Post by Stefan Kottwitz »

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
LaTeX.org admin
Post Reply