1

I'd like to reproduce the following 3d image using pgfplots enter image description here

the battery doesn't need to be there, just the closed path and the axis.

I haven't been able to find any examples of 3d paths that are not expressible as parametric functions, but that are user-defined, seemingly random paths. Any idea on how to achieve this?

  • Please, could you add a minimal working example? Did you tried something? – Sebastiano Nov 17 '18 at 13:17
  • I didn't add a MWE because, well, there wasn't. I mean, basically the only part of the image i want to replicate is the 3d path, which is what I don't know how to do. – noibe Nov 17 '18 at 13:26
  • 2
    Why pgfplots and not tikz-3dplot? – user121799 Nov 17 '18 at 16:30
  • Well I used pgfplots for all the other images in the document I'm working on, but if the end result is similar in style, then tikz-3dplot will be fine, too. – noibe Nov 17 '18 at 16:41
5

This is just a quick attempt to produce some curve that somewhat resembles the one on your screen shot. Obviously, you do not necessarily need a parametrization, you could also draw a smooth curve through a set of known coordinates. However, as I know neither parametrization nor coordinates, this is a quick example that should give you an idea how things may look like.

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{tikz-3dplot}
\begin{document}
\tdplotsetmaincoords{70}{130}
\begin{tikzpicture}
\begin{scope}[tdplot_main_coords]
\pgfmathsetmacro{\Radius}{3}
\draw[-latex]   (0,0,0) --  (1.5*\Radius,0,0) node[pos=1.1]{$x$};
\draw[-latex]   (0,-1.5*\Radius,0) --   (0,1.5*\Radius,0) node[pos=1.05]{$y$};
\draw[-latex]   (0,0,0) --  (0,0,1.5*\Radius) node[pos=1.1]{$z$};
\draw[double] plot[variable=\x,domain=360:0,samples=181] 
({\Radius*cos(\x)},{\Radius*sin(\x)},{2.5+\Radius*cos(2*\x)/2});
\draw (0,0,0.75*\Radius) -- (0,0,1.45*\Radius);
\end{scope}
\end{tikzpicture}
\end{document}

enter image description here

Sure enough, you can draw a 3D curve it with pgfplots as well.

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}
\begin{axis}[axis lines=middle,view={135}{45},xlabel=$x$,
ylabel=$y$,zlabel=$z$,clip=false,xtick=\empty,ytick=\empty,ztick=\empty]
\pgfmathsetmacro{\Radius}{3}
\addplot3[double,domain=360:0,samples=181,samples y=1] 
({\Radius*cos(x)},{\Radius*sin(x)},{2.5+\Radius*cos(2*x)/2});
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.