我想要得到一个如图所示的轴系统。
我尝试反转轴,但标签轴未放置在正确的位置。我可以重命名轴的其余部分,但绘制所有图形时改变坐标实在是太不舒服了。
请帮我。
\documentclass{report}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{
compat=1.8,
every axis/.append style={
axis lines=center,
xlabel style={anchor=south west},
ylabel style={anchor=south west},
zlabel style={anchor=south west},
tick align=outside,
},
}
\begin{document}
\begin{tikzpicture}
\begin{axis} [
xlabel={$x$},
%ylabel={$z$},
zlabel={$y$},
y dir=reverse,
]
\addplot3+ coordinates {(0,0,0) (4,0,0) (4,0,4) (0,0,4) (0,0,0)};
\end{axis}
\end{tikzpicture}
\end{document}
答案1
您可以使用 更改轴的方向x=..., y=..., z=...
。以下是示例:
\documentclass[tikz, border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}
\begin{document}
\begin{tikzpicture}
\begin{axis} [
axis lines=center,
x={(.5cm,-0.1cm)}, y={(0cm,0.5cm)}, z={(-0.3cm,-0.3cm)},
xlabel={$x$},
ylabel={$y$},
zlabel={$z$},
xmax=8, ymax=4, zmax=8,
ticks=none,
clip=false
]
\addplot3+ coordinates {(0,0,0) (4,0,0) (4,0,4) (0,0,4) (0,0,0)};
\addplot3+ coordinates {(0,2,0) (4,2,0) (4,2,4) (0,2,4) (0,2,0)};
\node at (0,2,4)[above left] {$P(0,2,4)$};
\end{axis}
\end{tikzpicture}
\end{document}
答案2
您可以3dtools
使用这里
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{calc,3dtools}% https://github.com/marmotghost/tikz-3dtools
\begin{document}
\begin{tikzpicture}[line cap=round,line join=round,
3d/install view={phi=100,theta=70}]
\path (1,0,0) coordinate (ez) (0,1,0) coordinate (ex)
(0,0,1) coordinate (ey);
\begin{scope}[x={(ex)},y={(ey)},z={(ez)}]
\draw[-stealth,thick] (0,0,0) -- (5,0,0) node[pos=1.05]{$x$};
\draw[-stealth,thick] (0,0,0) -- (0,3.5,0) node[pos=1.05]{$y$};
\draw[-stealth,thick] (0,0,0) -- (0,0,6.5) node[pos=1.15,thick]{$z$};
\draw[thick] (0,0,0) -- (4,0,0)-- (4,0,4)-- (0,0,4)-- (0,0,0)
(0,2,0)-- (4,2,0)-- (4,2,4) --(0,2,4) --(0,2,0)
(0,0,4) -- (0,2,4)
(4,0,4) -- (4,2,4)
(4,0,0) -- (4,2,0)
;
\node at (0,2,4)[above left] {$P(0,2,4)$};
\end{scope}
\end{tikzpicture}
\end{document}