TikZ/pgfplots 的 3D 箭头提示

TikZ/pgfplots 的 3D 箭头提示

我非常喜欢如何摆脱 Asymptote 3D 图形中查看器的(错误)轴并且想知道如何在中生成这个pgfplots

在此处输入图片描述 在此处输入图片描述

我承认我还没有尝试过,但是可以采用类似以下解决方案TikZ 中的截止锥似乎有点多,所以在我追求这个想法之前,我会看看这是否已经在某些 3D 库中可用。

下面的代码是使用自定义单位向量绘制 3D 轴网格并设置基本的3d轴和网格。

代码:

\documentclass[border=3pt]{standalone}

\usepackage{xparse}
\usepackage{tikz}
\usetikzlibrary{3d}

\NewDocumentCommand{\DrawCoordinateGrid}{O{} m m m m m m}{%
    \def\XGridMin{#2}
    \def\XGridMax{#3}
    \def\YGridMin{#4}
    \def\YGridMax{#5}
    \def\ZGridMin{#6}
    \def\ZGridMax{#7}
    %
    \begin{scope}[canvas is xy plane at z=0, thick, red]
      \draw [#1] (\XGridMin,\YGridMin) grid (\XGridMax,\YGridMax);
    \end{scope}
    \begin{scope}[canvas is yz plane at x=0, thin, blue]
      \draw [#1] (\YGridMin,\ZGridMin) grid (\YGridMax,\ZGridMax);
    \end{scope}
    \begin{scope}[canvas is xz plane at y=0, thin, orange]
      \draw [#1] (\XGridMin,\ZGridMin) grid (\XGridMax,\ZGridMax);
    \end{scope}
}%

\NewDocumentCommand{\DrawCoordinateAxis}{O{} m m m m m m}{%
    \def\XAxisMin{#2}
    \def\XAxisMax{#3}
    \def\YAxisMin{#4}
    \def\YAxisMax{#5}
    \def\ZAxisMin{#6}
    \def\ZAxisMax{#7}
    %
    \begin{scope}[thin, gray, -latex]
        \draw [#1] (\XAxisMin,0,0) -- (\XAxisMax,0,0) node [below left] {$x$};
        \draw [#1] (0,\YAxisMin,0) -- (0,\YAxisMax,0) node [right] {$y$};
        \draw [#1] (0,0,\ZAxisMin) -- (0,0,\ZAxisMax) node [above] {$z$};
    \end{scope}
}%

\begin{document}
\begin{tikzpicture}[
    x={(1.0cm,0.0cm)}, y={(0.0cm,1.0cm), z={(-0.5cm,-0.1cm)}}% All grids are ok
    ]

    \DrawCoordinateGrid{0}{4}{0}{4}{0}{4}
    \DrawCoordinateAxis[thick, black]{0}{5}{0}{5}{0}{5}
\end{tikzpicture}
\end{document}

答案1

更新

有可能获得更好的集成。第一次尝试给出此代码

\documentclass{scrartcl}
\usepackage{tikz}
\usetikzlibrary{3d}   
\begin{document}

\newcommand*\elevation{20}
\newcommand*\anglerot{-50}
\pgfmathsetmacro\xc{cos(\anglerot)}   
\pgfmathsetmacro\xs{sin(\anglerot)} 
\pgfmathsetmacro\yc{cos(\elevation)}   
\pgfmathsetmacro\ys{sin(\elevation)}
\newcommand*\axexthreed{\xs*1cm,-\xc*1cm} 
\newcommand*\axeythreed{\yc*1cm,-\ys*1cm}
\newcommand*\axezthreed{0cm,1cm} 

\newcommand*{\arrowthreeD}[3]{%
\draw[#1!50!black,
     ball color=#1,
     shift = {#2},
     rotate=#3]
     (0,0) -- (75:.8mm) arc (75:105:.8mm)--cycle; 
}
\begin{tikzpicture}[x = {(\axexthreed)},
                    y = {(\axeythreed)},
                    z = {(\axezthreed)},
                    scale = 4]
   \begin{scope}[canvas is zy plane at x=0]
     \draw[green!50!blue] (.5,.5) circle (.5cm); 
     \draw [green!50!blue,step=.1] (0,0) grid (1,1);  
   \end{scope}
   \begin{scope}[canvas is zx plane at y=0]
     \draw[blue!50!red] (.5,.5) circle (.5cm); 
     \draw [blue!50!red,step=.1] (0,0) grid (1,1); 
   \end{scope} 
   \begin{scope}[canvas is yx plane at z=0]
     \draw[red!50!green] (.5,.5) circle (.5cm);
     \draw [red!50!green,step=.1] (0,0) grid (1,1);   
   \end{scope} 

\draw[red]   (0,0,0) -- (.95,0,0)    node[red,left=6pt]    {$x$}; 
\draw[green] (0,0,0) -- (0,.95,0)    node[green,right=6pt] {$y$}; 
\draw[blue]  (0,0,0) -- (0,0,.95)    node[blue,above=6pt]  {$z$};       
\arrowthreeD{blue}{(\axezthreed)}{180}
\arrowthreeD{red}{(\axexthreed)}{\anglerot} 
\arrowthreeD{green}{(\axeythreed)}{90-\elevation}    
\end{tikzpicture} 
\end{document} 

在此处输入图片描述

相关内容