# Drawing closed 3d path with pgfplots

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

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
• 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

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]
\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]
\end{scope}
\end{tikzpicture}
\end{document}


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]