Is there any difference between those two tikz libraries for 3D plots?
I have found the documentation for tikz-3dplot on CTAN, but nothing for the \usetikzlibrary{3d}.
Might be related to Documentation of the tikz 3d library
Is there any difference between those two tikz libraries for 3D plots?
I have found the documentation for tikz-3dplot on CTAN, but nothing for the \usetikzlibrary{3d}.
Might be related to Documentation of the tikz 3d library
tikz-3dplot (without an s in the end) loads the 3d library (and also calc) automatically. So it has all the features of the 3d library simply because it loads it. In addition, it has commands that allow one to install a 3d view like \tdplotsetmaincoords and \tdplotsetrotatedcoords, and means to do real 3d plots (hence the name). Other ways of installing a 3d view in TikZ are to use the perspective library (the key is called 3d view) or pgfplots (the key is view and similar keys). The conventions for the view angles differ, unfortunately, between these packages/libraries.
The main purpose of the 3d library is to switch to coordinate planes (such as canvas is xy plane at z=<z>), which is of course something that makes most sense once you have established a proper 3d view.
3d coordinates are supported by TikZ without further ado. However, the predefined view is not orthographic. You can rectify this by carefully choosing x, y and z, but it is much more convenient to use the above-mentioned tools for that.
This example is supposed to illustrate some of these statements.
\documentclass[tikz,border=3mm]{standalone}
\usepackage{tikz-3dplot}
\usetikzlibrary{perspective}
\begin{document}
\begin{tikzpicture}[cube/.style={insert path={
(-1,-1,-1) edge ++(0,0,2) -- (1,-1,-1) edge ++(0,0,2)
-- (1,1,-1) edge ++(0,0,2) -- (-1,1,-1) edge ++(0,0,2) -- cycle
(-1,-1,1) -- (1,-1,1) -- (1,1,1) -- (-1,1,1) -- cycle
}}]
\def\LabelPlanes{
\node[canvas is xy plane at z=1,transform shape]{xy plane};
\node[canvas is xz plane at y=1,transform shape]{xz plane};
\node[canvas is yz plane at x=1,transform shape]{yz plane};}
\begin{scope}[local bounding box=A]
\draw[cube];
\LabelPlanes
\end{scope}
\path (A.south) node[below]{plain Ti\emph{k}Z};
%
\tdplotsetmaincoords{70}{110}% theta,phi
\begin{scope}[xshift=4cm,tdplot_main_coords,local bounding box=B]
\draw[cube];
\LabelPlanes
\end{scope}
\path (B.south) node[below]{\texttt{tikz-3dplot}};
%
\begin{scope}[xshift=8cm,3d view={110}{20},% phi,90-theta of tikz-3dplot
local bounding box=C]
\draw[cube];
\LabelPlanes
\end{scope}
\path (C.south) node[below]{\texttt{perspective}};
\end{tikzpicture}
\end{document}
The left-most picture is not an orthographic projection of a cube, but shows that you can use 3d coordinates in TikZ right away. The next pictures show the cube in the same projection in tikz-3dplot and perspective, and one can see that the conventions for the latitude angle (usually called theta) differ. The example also illustrates one, perhaps the main, application of the 3d library: project something on a coordinate plane. This works with nodes, as illustrated, but of course also with drawings and external graphics.
Note that the main purpose of the perspective library is not to install a 3d view. Rather, as its name suggests, it allows one to install a 3 point perspective view, yet this discussion is beyond the scope of this answer.
3d tikzlibrary. – leandriis Mar 27 '20 at 15:39