如何绘制这些框和箭头?

如何绘制这些框和箭头?

有没有简单的代码可以让我画这些?我不具备理解乳胶代码的能力。比如

p1=[0,5]
p2=[0,10]
...
draw.box(p1=p1,p2=p2,...)
draw.box(...)
draw.arrow(...)

在此处输入图片描述

答案1

重复提问,重复回答。

\documentclass[tikz,border=3.14mm]{standalone}
\tikzset{pics/empty fake box/.style args={% #1=color, #2=x dimension, #3=y dimension, #4=z dimension
#1 with dimensions #2 and #3 and #4}{
code={
\draw[ultra thin,fill=#1]  (0,-#3/2,-#4/2) coordinate(-front-bottom-left) to
++ (0,#3,0) coordinate(-front-top-left) --++
(#2,0,0) coordinate(-front-top-right) --++ (0,-#3,0) 
coordinate(-front-bottom-right) -- cycle;
\draw[ultra thin,fill=#1] (0,#3/2,-#4/2)  --++ 
 (0,0,#4) coordinate(-back-top-left) --++ (#2,0,0) 
 coordinate(-back-top-right) --++ (0,0,-#4)  -- cycle;
\draw[ultra thin,fill=#1!80!black] (0,-#3/2,-#4/2) --++ (0,0,#4) coordinate(-back-bottom-right)
--++ (0,#3,0) --++ (0,0,-#4) -- cycle;
}
}}
\begin{document}

\begin{tikzpicture}[x={(1,0)},y={(0,1)},z={({-cos(60)},{sin(60)})},
font=\sffamily\small,scale=2,declare function={gap=0.7;}]
%
% comment these out if you want to see where the axes point to
% \draw[-latex] (0,0,0) -- (3,0,0) node[below]{$x$};
% \draw[-latex] (0,0,0) -- (0,3,0) node[left]{$y$};
% \draw[-latex] (0,0,0) -- (0,0,3) node[below]{$z$};
\node[circle,draw,inner sep=0pt,anchor=west,font=\Large] (p1) at (0,0,0) {+};
\foreach \X/\Y/\Z [count=\N] in {0.4/0.5/0.6,0.3/1.5/1.2,0.3/0.7/1.2}
{
\draw[very thick,-latex] (-\N*gap,0,0) -- ++ (gap,0,0);
\draw pic (box1-\N) at (-\N*gap,0,0) 
{empty fake box=orange!90!black with dimensions {\X} and {\Y} and \Z};
}
\node[circle,draw,inner sep=0pt,anchor=west,font=\Large] (p2) at (-4*gap,0,0) {+};
\draw[very thick,densely dashed] (p2.east) -- (-3.5*gap,0,0);
\draw[very thick,-latex] (-3.5*gap,0,0) -- ++ (0.5*gap,0,0);
\draw[very thick,densely dashed,-latex] (p2.north) -- ++(0,0.8,0) -| (p1);
\foreach \X/\Y/\Z [count=\N] in {0.4/0.5/0.6,0.3/1.5/1.2,0.3/0.7/1.2,0.2/1.7/1.3}
{
\draw[very thick,-latex] (-\N*gap-4*gap,0,0) -- ++ (1*gap,0,0);
\draw pic (box1-\N) at (-\N*gap-4*gap,0,0) 
{empty fake box=orange!90!black with dimensions {\X} and {\Y} and \Z};
}
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容