答案1
您可以使用3d工具
\documentclass[tikz,border=3mm]{standalone}
\usepackage{tikz-3dplot}
\usetikzlibrary{3dtools}% https://github.com/marmotghost/tikz-3dtools
\begin{document}
\begin{tikzpicture}[3d/install view={phi=110,theta=70},line join = round, line cap = round,c/.style={circle,fill,inner sep=1pt},
declare function={R=3;h=3;}]
\path (0,0,0) coordinate (O)
(0,0,h) coordinate (O');
\path[save named path=ox] (-R-1,0,0) -- (R+ 3,0,0) node[anchor=north east]{$x$};
\path [save named path=oy] (0,-R-2,0) -- (0,R+2,0) node[anchor=north west]{$y$};
\path [save named path=oz] (0,0,0) -- (0,0,h+2) node[anchor=south]{$z$};
\path [save named path=oz'] (0,0,0) -- (0,0,-h);
\path [3d/visible/.style={save named path=cyc,draw={none}}] pic{3d/frustum={R=R,r=R,h=h}};
\draw[3d/hidden,blue] (O) -- (O');
\draw[3d/visible, - latex,blue] (O') -- (0,0,h+2);
\tikzset{3d/ordered paths/.cd,ox/.style={blue,- latex},oy/.style={blue,- latex},oz'/.style={blue}}
\tikzset{3d/draw ordered paths={ox,oy,oz',cyc}}
%\path foreach \p/\g in {O/-90}{(\p)node[c]{}+(\g:2.5mm) node{$\p$}};
\end{tikzpicture}
\end{document}
我添加了一些节点
\documentclass[tikz,border=3mm]{standalone}
\usepackage{tikz-3dplot}
\usetikzlibrary{3dtools}% https://github.com/marmotghost/tikz-3dtools
\begin{document}
\begin{tikzpicture}[3d/install view={phi=110,theta=70},line join = round, line cap = round,c/.style={circle,fill,inner sep=1pt},
declare function={R=3;h=3;}]
\path (0,0,0) coordinate (O)
(0,0,h) coordinate (O');
\path[save named path=ox] (-R-1,0,0) -- (R+ 3,0,0) node[anchor=north east]{$x$};
\path [save named path=oy] (0,-R-2,0) -- (0,R+2,0) node[anchor=north west]{$y$};
\path [save named path=oz] (0,0,0) -- (0,0,h+2) node[anchor=south]{$z$};
\path [save named path=oz'] (0,0,0) -- (0,0,-h);
\path [3d/visible/.style={save named path=cyc,draw={none}}] pic{3d/frustum={R=R,r=R,h=h}};
\draw[3d/hidden,blue] (O) -- (O');
\node[below] at (0,R,0) {$ r $};
\node[below] at (0,-R,0) {$ -r $};
\node[right] at (0,0,h) {$ h $};
\draw[3d/visible, - latex,blue] (O') -- (0,0,h+2);
\tikzset{3d/ordered paths/.cd,ox/.style={blue,- latex},oy/.style={blue,- latex},oz'/.style={blue}}
\tikzset{3d/draw ordered paths={ox,oy,oz',cyc}}
\end{tikzpicture}
\end{document}
答案2
这可能有助于开始:使用 pgfplot 圆柱作为 tikz 节点的坐标系
\documentclass[border=0.5cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric,calc}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
view={25}{15},
axis lines=center,
width=20cm,height=20cm,
xmin=-5,xmax=5,ymin=-5,ymax=5,zmin=-5,zmax=5,
xlabel={$x$},ylabel={$y$},zlabel={$z$},
]
\node[cylinder,draw=black,thick,aspect=0.9,minimum height=1.2cm,minimum width=1cm,shape border rotate=90,fill=white] at (axis cs:0,0,0.25) {};
\end{axis}
\end{tikzpicture}
\end{document}