在 LaTeX 中绘制 3D 图表

在 LaTeX 中绘制 3D 图表

我目前正在写我的学士论文,在 3D 图表方面遇到了麻烦。到目前为止,我一直在使用 Inkscape,但我对它的外观并不满意。尤其是箭头的外观。如果有人对我应该使用什么应用程序有任何建议,我会非常高兴。

这就是我希望我的图表的样子: 在此处输入图片描述 我也尝试过 TikZ,但是它花费的时间太长了。

答案1

用 Ti 绘制图形Z 不会花费太长时间。对于 Ti 来说可能确实如此。Z 新用户,但这是值得投资的时间,因为从长远来看,您将能够在短时间内制作出这样的图纸。

例如,使用等距透视,3D 部分将是这样的:

\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{3d}                   % for canvas is... options
\usetikzlibrary{decorations.markings} % for arrows at midpath

% isometric perspective
\pgfmathsetmacro\xx{1/sqrt(2)}
\pgfmathsetmacro\xy{1/sqrt(6)}
\pgfmathsetmacro\zz{sqrt(2/3)}
\tikzset
{%
  isometric/.style={x={(-\xx cm,-\xy cm)},y={(\xx cm,-\xy cm)},z={(0cm,\zz cm)}},
% arrows
  my arrow/.style 2 args={decoration={markings,mark=at position #1 with
                          {\node[right] {$#2$}; \arrow{stealth}}},                                          
                          postaction={decorate}},
}

\begin{document}
\begin{tikzpicture}[isometric,scale=2]
% axes
\draw[dashed] (0,0,0) -- (1,0,0) coordinate (X);
\draw[dashed] (0,0,0) -- (0,1,0) coordinate (Y);
\draw[dashed] (0,0,0) -- (0,0,1) coordinate (Z);
\draw[-latex] (X) -- (2,0,0) node [left]  {$x$};
\draw[-latex] (Y) -- (0,2,0) node [right] {$y$};
\draw[-latex] (Z) -- (0,0,2) node [above] {$z$};
% equator
\begin{scope}[canvas is xy plane at z=0,blue]
  \draw                 (-45:1) arc (-45:135:1);
  \draw[loosely dashed] (315:1) arc (315:135:1);
\end{scope}
% meridian
\begin{scope}[canvas is xz plane at y=0,red]
  \draw[thick,my arrow={0.7}{4}] (-45:1) arc (-45: 90:1);
  \path[thick,my arrow={0.9}{2}] ( 90:1) arc ( 90:-45:1);
  \draw[thick,dashed]            (-90:1) arc (-90:-45:1);
  \draw                          ( 90:1) arc ( 90:135:1);
  \draw[dashed]                  (135:1) arc (135:270:1);
  
\end{scope}
% sphere
\draw (0,0,0) circle (1cm);
% dots
\foreach\z in {1,3}
  \fill[red] (0,0,2-\z) circle (0.5pt) node[below right] {$\z$};
\foreach\i in {X,Y}
  \fill (\i) circle (0.5pt);
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

我能想到的最好的方法是使用包tikz-3dplot。您可以通过以下链接查看文档:tikz-3dplot_文档您还可以查看这个使用相同包来生成图形的示例:tikz-3dplot_示例

答案3

这不是一个完整的答案。你可以尝试

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{3dtools}
\begin{document}
    \begin{tikzpicture}[3d/install view={phi=110,theta=70},line cap=butt,
    line join=round,declare function={R=2.5;},c/.style={circle,fill,inner sep=1pt}] 
    \tikzset
    {axis/.style={blue,- latex}};
    \path
    (0,0,0) coordinate (O)
    (0,0,R)  coordinate (N)
    (0,0,-R)  coordinate (S);
    \path[save named path=sph,3d/screen coords] (O) circle[radius=R];
    \path pic{3d/circle on sphere={R=R,C={(O)}}};
    \path  pic{3d/circle on sphere={R=R,C={(O)},P={(O)}, n={(1,-9,0)}}}; 
    
    \path[save named path=ox] (0,0,0) -- (R+5,0,0) node[anchor=north east]{$x$};
    \path [save named path=oy] (0,0,0) -- (0,R+2,0) node[anchor=north west]{$y$};
    \path [save named path=oz] (0,0,0) -- (0,0,R+1.5) node[anchor=south]{$z$};
    \draw[3d/hidden] (S) -- (O);
        \tikzset{3d/ordered paths/.cd,ox/.style={blue,- latex},oy/.style={blue,- latex},oz/.style={blue,-latex}}
    \tikzset{3d/draw ordered paths={ox,oy,oz,sph}}
    \path foreach \p/\g in {O/-30,S/0,N/-30}
    {(\p)node[c]{}+(\g:2.5mm) node{$\p$}};
    \end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容