I have two 3D plots, one in polar coordinates, the other parametric. I'd like to have on the same plot also the contours. These are the current plots:

Elliptic paraboloid

      \addplot3 [surf,z buffer=sort,samples=30,domain=0:360,y domain=0:5, data cs=polar] (x,y,y^2);
      \addplot3 [contour gnuplot={contour dir=y,draw color=red,labels=false},y filter/.expression={5},] {x^2};
      \addplot3 [contour gnuplot={contour dir=x,draw color=blue,labels=false},x filter/.expression={5},] {y^2};

Elliptic hyperboloid

    \addplot3[surf,domain=-1:1,y domain=0:360,z buffer=sort] ({cosh(x)*cos(y)}, {cosh(x)*sin(y)}, {sinh(x)});

My question now is: how could I automatically plot the contours of both plots since they are defined via polar coordinates or parameters? The x and y contours of the paraboloid are just hardcoded.

I am looking for (if there is one) a way to create automatically the contours, without caring what coordinates it is using. Kind of like the example at page 156 here

I have also managed to get something like this pt2 adding the following line:

\addplot3 [contour gnuplot={contour dir=z,draw color=black,labels=false},z filter/.expression={25},] {y^2+x^2};

but the solution does not seem optimal since I have to manually know the section. Is there a way to achieve this?

Edit 1: I perhaps should clarify my need. Suppose I have a function f that I want to plot. I can use its cartesian formula, some parameterization or use polar coordinates. Either way, the same result should be achieved. In the first case, finding contours with the aid of contour gnuplot is quite easy and I just have to input the original function.

If I have f in a parametric form or that is using polar coordinates though, I have to already know the contour equations to plot them. Is there a way to generalize the problem s that for any given f written in any form, I am able to plot the contours?

Basically I would like to have the projection of the function f on the axis and plot its countour.

  • Nothing actually prevents me from using it to be completely fair. I would just like a more automated way. In the example I linked, the contour was not "hardcoded" but the function (the hyperbolic paraboloid) was just passed as parameter. I would like to know if I have to manually know the contours (that in some cases might be very complicated) or I can let pgf do the work for me even for the more complex functions. – gjkf Mar 2 at 18:20
  • Not really. Perhaps the whole question is meaningless and I am just missing a point. Let's take the second function (x^2+y^2-z^2=1) I would like to have the same kind of contours on the box, as the example on the manual. The thing is that the function is in the parametric form. I was asking myself if there was a way to create the contours without manually plotting them one by one (the example on the manual has multiple contour lines with a single call). Of course I could just plot them by hand but perhaps with more complex functions, this would be unfeasible. – gjkf Mar 2 at 18:45
  • Sorry if I didn't express myself clearly the first time. I too wasn't sure which terms to use. I hope I now made my problem clear. If that is not the case, I'll try to explain it even further. – gjkf Mar 2 at 19:10
  • Correct. And if possible learn a way to generalize the problem and/or apply it to any kind of surface. – gjkf Mar 2 at 19:26
  • I just removed my answer an remove my comments because I seem to be on the wrong track. Hope someone else will have more luck. – marmot Mar 2 at 23:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.