我正在尝试更改此代码,以便我的虚线从第一个矩形开始,就像在第二个矩形中一样。另外,我如何删除第二个矩形上的向上轴?
代码:
\begin{document}
\tdplotsetmaincoords{70}{20}
\begin{tikzpicture}[tdplot_main_coords,
declare function={pX=2;}]
\begin{scope}[canvas is yz plane at x=0]
\draw (-pX,-pX) coordinate (bl1) -- (pX,-pX) coordinate (br1)
-- (pX,pX) coordinate (tr1) -- (-pX,pX) coordinate (tl1) -- cycle;
\draw[stealth-stealth] (0,pX) node[below left]{$$}
-- (0,0) -- (pX,0) node[below left]{$$};
\pgflowlevelsynccm
\end{scope}
%\foreach \X in {bl,tl,br,tr}
%{\draw[-latex] (\X1) -- ++ (1,0,0);}
%
%\draw (0,0,0) -- (4,0,0);
% plane
\fill[gray,fill opacity=0.1] (-1,-4,0) -- (7,-4,0) --
(7,4,0) -- (-1,4,0) -- cycle;
\begin{scope}[canvas is yz plane at x=4]
\draw (-pX,-pX) coordinate (bl2) -- (pX,-pX) coordinate (br2)
-- (pX,pX) coordinate (tr2) -- (-pX,pX) coordinate (tl2) -- cycle;
\draw[stealth-stealth] (0,pX) -- (0,0) -- (pX,0);
\end{scope}
\draw[-latex] (4,0,0) -- (5.5,0,0) node[below left]{$$};
%\foreach \X in {bl,tl,br,tr}
%{\draw[-latex] (\X2) -- ++ (1,0,0);}
\begin{scope}[canvas is xy plane at z=0]
\begin{scope}
\clip (0,-2) rectangle (4,3);
\foreach \X in {0.25,0.75,...,5}
{\pgfmathsetmacro{\myrnd}{rnd*360}
\foreach \Y in {-1.75,-1.25,...,1.75}
{
\draw[-stealth] ({\X-0.2*cos(\myrnd)},{\Y-0.2*sin(\myrnd)}) --
({\X+0.2*cos(\myrnd)},{\Y+0.2*sin(\myrnd)});
}
\draw[densely dashed] (\X+.25,-2) -- (\X+0.25,2);}
% \foreach \X in {-2,-1.6,...,2}
% {\draw (0,\X) parabola ++(5,1);}
\end{scope}
\end{scope}
\end{tikzpicture}
答案1
为了绘制额外的虚线,可以在foreach
循环前添加一条线:
\draw[densely dashed] (0,-2) -- (0,2);
我不确定哪个矩形是第二个。轴由两个\draw[stealth-stealth]
命令定义。