0

I'm trying to change this code so that my dashed lines start at the first rectangle, like how they are at the second rectangle. Also, how can I delete the upward axis on the second rectangle?

Code:

\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} 

Output enter image description here

1
  • 1
    When making an MWE, please remember to keep it compilable: retain all the usepackage lines necessary.
    – Joce
    Nov 14 '19 at 10:36
2

In order to draw an additional dashed line, you can add a line before the foreach loop :

\draw[densely dashed] (0,-2) -- (0,2);

I am not sure which rectangle is the second. The axes are defined by the two \draw[stealth-stealth] commands.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.