我正在重新创建该图表。
我不太清楚如何缩放 z 轴以使其看起来像这样。
这是我目前所拥有的:
\documentclass[8pt]{extarticle}
\usepackage{amsmath, amssymb, calc}
\usepackage{pgfplots}
\usetikzlibrary{positioning, angles, quotes, arrows.meta, decorations.pathreplacing,calligraphy,backgrounds, decorations.markings, bending}
\pgfplotsset{compat=1.18}
\usepgfplotslibrary{external}
\usepgfplotslibrary{fillbetween}
\usepackage[utf8]{inputenc}
\usepackage{fourier}
\usepackage{cutwin}
\usepackage{tzplot}
\usepackage{tikz-3dplot}
\pgfplotsset{
every non boxed x axis/.style={
xtick align=center,
tick style={line width=0.5pt, color=black},
x axis line style={{Latex[width=1.5mm]}-{Latex[width=1.5mm]},black,line width=0.5pt},
xlabel style={at={(ticklabel* cs:1.05)}, anchor=mid},
xlabel=$x$
},
every non boxed y axis/.style={
ytick align=center,
tick style={line width=0.7pt, color=black},
y axis line style={{Latex[width=1.5mm]}-{Latex[width=1.5mm]},black,line width=0.5pt},
ylabel style={at={(ticklabel* cs:1.05)}, anchor=mid},
ylabel=$y$
},
every non boxed z axis/.style={
ztick align=center,
tick style={line width=0.5pt, color=black},
z axis line style={{Latex[width=1.5mm]}-{Latex[width=1.5mm]},black,line width=0.5pt},
zlabel style={at={(ticklabel* cs:1.05)}, anchor=mid},
zlabel=$z$
},
tick label style={
font=\tiny,
}
}
\definecolor{blue1}{RGB}{66, 127, 187}
\definecolor{purple1}{RGB}{177, 15, 189}
\begin{document}
\begin{tikzpicture}
\begin{axis}[axis on top, xmin=-3,xmax=3,ymin=-3,ymax=3,zmin=-2,zmax=4,axis lines=center,view/v=45,view/h=45,scale=2,xtick={-2,-1,0,1,2}, ytick={-2,-1,0,1,2},ztick={-1,0,1,2,3}]
\fill[gray,opacity=0.45] (-2.5,-2.5,0) -- (-2.5,2.5,0) -- (2.5,2.5,0) -- (2.5,-2.5,0) -- cycle;
\fill[blue1,opacity=0.5] (0,0,0) -- (0,1,2) -- (1,2,3) -- cycle;
\fill[purple1,opacity=0.5] (0,0,0) -- (0,1,2) -- (-2,0,1);
\draw[red, dashed, line width=0.5pt] (1,0,0) -- (1,2,0);
\draw[red, dashed, line width=0.5pt] (1,2,0) -- (0,2,0);
\draw[red, dashed, line width=0.5pt] (1,2,0) -- (1,2,3);
\fill[black] (1,2,3) circle [radius=2.5pt];
\draw[red, dashed, line width=0.5pt] (0,1,0) -- (0,1,2);
\draw[red, dashed, line width=0.5pt] (-2,0,0) -- (-2,0,1);
\draw[-{Latex[width=1.5mm]}, line width=1.5pt] (0,0,0) -- (0,1,2);
\draw[-{Latex[width=1.5mm]}, line width=1.5pt] (0,0,0) -- (1,2,3);
\fill[black] (0,1,2) circle [radius=2.5pt];
\draw[-{Latex[width=1.5mm]}, line width=1.5pt] (0,0,0) -- (-2,0,1);
\fill[black] (-2,0,1) circle [radius=2.5pt];
\end{axis}
\end{tikzpicture}
\end{document}
答案1
只是一个建议,但也许 Ti钾对于该图来说,Z 比 PGFPlots 更好吗?
isometric view
您可以使用库中的表单解决问题perspective
。其余的在 Ti 中更容易钾Z 保存蜱虫,但您可以使用\pic
该任务。
例如:
\documentclass[tikz,border=1.618mm]{standalone}
\usetikzlibrary{3d,perspective}
% colors, styles and a \pic for the tikcs
\definecolor{blue1} {RGB}{066,127,187}
\definecolor{purple1}{RGB}{177,015,189}
\tikzset
{
point/.style={circle,fill,inner sep=0.4mm},
pics/tick/.style=
{
/tikz/transform shape,
code=
{
\draw (0.05,0) --++ (-0.1,0);
\draw (0,0.05) --++ (0,-0.1) node[pos=3,transform shape=false] {$#1\ifnum#1<0\phantom{-}\fi$};
}
}
}
\begin{document}
\begin{tikzpicture}[scale=2,isometric view,rotate around z=-90,line join=round]
% coordinates
\coordinate (O) at (0,0,0);
\coordinate (A) at (1,2,3);
\coordinate (B) at (0,1,2);
\coordinate (C) at (-2,0,1);
% plane
\fill[gray,opacity=0.45,canvas is xy plane at z=0] (-2.5,-2.5) rectangle (2.5,2.5);
% axes
\draw[latex-latex] (-2.8,0,0) -- (2.8,0,0) node[right] {$x$};
\draw[latex-latex] (0,-2.8,0) -- (0,2.8,0) node[above] {$y$};
\draw[latex-latex] (0,0,-1.8) -- (0,0,3.8) node[above] {$z$};
% red dashed lines
\draw[red,dashed] (1,2,0) -- (A);
\draw[canvas is xy plane at z=0,red,dashed] (1,0) |- (0,2);
\draw[canvas is yz plane at x=0,red,dashed] (1,0) |- (0,2);
\draw[canvas is xz plane at y=0,red,dashed] (-2,0) |- (0,1);
% ticks
\foreach\i in {-2,-1,1,2}
{
\pgfmathtruncatemacro\j{\i==-1?\i+2:\i+1}
\pic[canvas is xy plane at z=\j] {tick=\j};
\pic[canvas is xz plane at y=\i] {tick=\i};
\pic[canvas is yz plane at x=\i] {tick=\i};
}
% triangles
\fill[blue1 ,opacity=0.5] (A) -- (O) -- (B);
\fill[purple1,opacity=0.5] (C) -- (O) -- (B);
% vectors with points
\foreach\i in {A,B,C}
\draw[thick,-latex] (O) -- (\i) node[point] {};
\end{tikzpicture}
\end{document}