TikZ 图的方向

TikZ 图的方向

我设计了一个图,代码如下

\documentclass{article}
\usepackage{stanli} 
\usepackage{tikz-3dplot}

\begin{document}
\begin{figure}
    \centering 
    \setcoords{-25}{10}[1][1.2]
    \setaxis {2}
    \begin{tikzpicture}[scale=1.1,thick=1.5]
    \begin{scope}[xshift=-2cm]
    \draw [->,dashed] (0,0,0) -- (2,0,0)  node [right] {$X$};
    \draw [->,dashed] (0,0,0) -- (0,2,0) node [left] {$Y$};
    \draw [->,dashed] (0,0,0) -- (0,0,2) node [right] {$Z$};  
    \end{scope}
    \begin{scope}
    \coordinate (A) at (-1,-1,-1);
    \coordinate (B) at (1.82, -1.56, -1); 
    \coordinate (C) at (1, 1, -1);
    \coordinate (D) at (-1, 1, -1); 
    \coordinate (E) at (-1,-1.94,1);
    \coordinate (F) at (1, -1, 1); 
    \coordinate (G) at (1.62, -0.29, 1);
    \coordinate (H) at (-1, 0.5, 1);
    \draw (A) -- (B) -- (C) -- (D) -- cycle; 
    \draw (E) -- (F) -- (G) -- (H) -- cycle; 
    \draw (A) -- (E) ; \draw(B) -- (F); \draw (C) -- (G); \draw (D) -- (H); 
    \end{scope}
    \begin{scope}[xshift=3.25cm]
    \draw [<->] (-0.95,0) -- (0.5,0);
    \node[above] (-0.95,20) {Mapping} ;
    \end{scope}
    \begin{scope}[xshift=5.5cm]
    \coordinate (A) at (-1,-1,-1);
    \coordinate (B) at (1, -1, -1); 
    \coordinate (C) at (1, 1, -1);
    \coordinate (D) at (-1, 1, -1); 
    \coordinate (E) at (-1,-1,1);
    \coordinate (F) at (1, -1, 1); 
    \coordinate (G) at (1, 1, 1);
    \coordinate (H) at (-1, 1, 1);
    \draw (A) -- (B) -- (C) -- (D) -- cycle; 
    \draw (E) -- (F) -- (G) -- (H) -- cycle; 
    \draw (A) -- (E) ; \draw(B) -- (F); \draw (C) -- (G); \draw (D) -- (H); 
    \draw [->,dotted] (0,0,0) -- (2.2,0,0) node [right] {$\xi$};
    \draw [->,dotted] (0,0,0) -- (0,2.2,0) node [above] {$\eta$};
    \draw [->,dotted] (0,0,0) -- (0,0,2.2) node [above] {$\omega$};
    \end{scope}
    \end{tikzpicture}
\end{figure}

\end{document} 

我希望 z 轴指向上方,但我无法使用tdsetmaincoords或任何相关指令来使 z 轴指向上方。

答案1

同时加载stanlitikz-3dplot有点过头了。你只是忘了把 放入coords选项中tikzpicture。我认为使用local bounding boxes 更容易实现你想要的(我猜)。

\documentclass{article}
\usepackage{tikz} 
%\usepackage{tikz-3dplot}
\usepackage{stanli} 

\begin{document}
\begin{figure}
    \centering 
    \setcoords{-25}{10}[1][1.2]%[1][0.5]
    \setaxis{2}
    \begin{tikzpicture}[coords,scale=1.1,thick=1.5]
    \begin{scope}[xshift=-2cm]
    \draw [->,dashed] (0,0,0) -- (2,0,0)  node [right] {$X$};
    \draw [->,dashed] (0,0,0) -- (0,2,0) node [left] {$Y$};
    \draw [->,dashed] (0,0,0) -- (0,0,2) node [right] {$Z$};  
    \end{scope}
    \begin{scope}[local bounding box=left]
    \coordinate (A) at (-1,-1,-1);
    \coordinate (B) at (1.82, -1.56, -1); 
    \coordinate (C) at (1, 1, -1);
    \coordinate (D) at (-1, 1, -1); 
    \coordinate (E) at (-1,-1.94,1);
    \coordinate (F) at (1, -1, 1); 
    \coordinate (G) at (1.62, -0.29, 1);
    \coordinate (H) at (-1, 0.5, 1);
    \draw (A) -- (B) -- (C) -- (D) -- cycle; 
    \draw (E) -- (F) -- (G) -- (H) -- cycle; 
    \draw (A) -- (E) ; \draw(B) -- (F); \draw (C) -- (G); \draw (D) -- (H); 
    \end{scope}
    \begin{scope}[xshift=6cm,yshift=-0.5cm,local bounding box=right]
    \coordinate (A) at (-1,-1,-1);
    \coordinate (B) at (1, -1, -1); 
    \coordinate (C) at (1, 1, -1);
    \coordinate (D) at (-1, 1, -1); 
    \coordinate (E) at (-1,-1,1);
    \coordinate (F) at (1, -1, 1); 
    \coordinate (G) at (1, 1, 1);
    \coordinate (H) at (-1, 1, 1);
    \draw (A) -- (B) -- (C) -- (D) -- cycle; 
    \draw (E) -- (F) -- (G) -- (H) -- cycle; 
    \draw (A) -- (E) ; \draw(B) -- (F); \draw (C) -- (G); \draw (D) -- (H); 
    \draw [->,dotted] (0,0,0) -- (2.2,0,0) node [right] {$\xi$};
    \draw [->,dotted] (0,0,0) -- (0,2.2,0) node [above] {$\eta$};
    \draw [->,dotted] (0,0,0) -- (0,0,2.2) node [above] {$\omega$};
    \end{scope}
    \draw [<->,shorten >=2pt,shorten <=2pt] (left.east) --
    (left.east-|right.west) node[midway,above,sloped]  {Mapping} ;
    \end{tikzpicture}
\end{figure}

\end{document} 

在此处输入图片描述

相关内容