6

I'm trying to combine two tikz plots together and having some trouble. I have the first plot which contains the 3d version, and then I have the second image which I want to map onto the first, in the grey plane section. I would really appreciate some help on doing this. Thanks.

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{tikz-3dplot}
\usetikzlibrary{arrows.meta,bending}
\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]{$x_2$}
   -- (0,0) --  (pX,0) node[below left]{$x_1$};
   \pgflowlevelsynccm
   \draw[-{Latex[bend]}] (2,0) arc(0:380:1);
   \draw[-{Latex[bend]}] (0,-1) arc(-90:290:1);
   \draw[-{Latex[bend]}] (0,0) arc(-90:380:1);
 \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.3] (-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);
   \pgflowlevelsynccm
   \draw[-{Latex[bend]}] (1,0) arc(0:380:0.25);
   \draw[-{Latex[bend]}] (0,-0.25) arc(-90:290:0.25);
   \draw[-{Latex[bend]}] (0,0.25) arc(-90:380:0.25);
 \end{scope}
 \draw[-latex] (4,0,0) -- (6,0,0) node[below left]{$x_3$};
 \foreach \X in {bl,tl,br,tr}
 {\draw[-latex] (\X2) -- ++ (1,0,0);}
\end{tikzpicture}
\end{document}

Second Image

   \documentclass[tikz,border=3.14mm]{standalone}
    \usepackage{tikz-3dplot}
    \usetikzlibrary{arrows.meta,bending}
    \begin{document}
    \begin{tikzpicture}
     \begin{scope}
      \clip (0,0) rectangle (4,3);
      \foreach \X in {-2,-1.6,...,2}
       {\draw (0,\X) parabola ++(5,2);}
     \end{scope} 
     \draw[-stealth] (-1,0) -- (5,0) node[below right]{$x_3$};
     \draw[-stealth] (0,-0.5) node[above left]{$0$} -- (0,3)
     node[right=2em,yshift=-1em]{$\theta(x_3)$};
     \draw[-stealth] (4,-0.5) node[above left]{$L$} -- (4,3) node[below right]{$x_1$};
    \end{tikzpicture}

    \end{document}

Image 1

enter image description here

1 Answer 1

8

Switch into the xy plane and you can reuse the code from the second image:

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{tikz-3dplot}
\usetikzlibrary{arrows.meta,bending}
\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]{$x_2$}
   -- (0,0) --  (pX,0) node[below left]{$x_1$};
   \pgflowlevelsynccm
   \draw[-{Latex[bend]}] (2,0) arc(0:380:1);
   \draw[-{Latex[bend]}] (0,-1) arc(-90:290:1);
   \draw[-{Latex[bend]}] (0,0) arc(-90:380:1);
 \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.3] (-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);
   \pgflowlevelsynccm
   \draw[-{Latex[bend]}] (1,0) arc(0:380:0.25);
   \draw[-{Latex[bend]}] (0,-0.25) arc(-90:290:0.25);
   \draw[-{Latex[bend]}] (0,0.25) arc(-90:380:0.25);
 \end{scope}
 \draw[-latex] (4,0,0) -- (6,0,0) node[below left]{$x_3$};
 \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,0) rectangle (4,3);
        \foreach \X in {-2,-1.6,...,2}
         {\draw (0,\X) parabola ++(5,2);}
       \end{scope} 
%       \draw[-stealth] (-1,0) -- (5,0) node[below right]{$x_3$};
%       \draw[-stealth] (0,-0.5) node[above left]{$0$} -- (0,3)
%       node[right=2em,yshift=-1em]{$\theta(x_3)$};
%       \draw[-stealth] (4,-0.5) node[above left]{$L$} -- (4,3) node[below right]{$x_1$};
  \end{scope}
\end{tikzpicture}
\end{document}

enter image description here

2
  • When I compile this I get the following image, imgur.com/a/BTVZgDF, do you know what the problem is? Jun 24, 2019 at 14:59
  • 1
    @rodger_kicks Most likely you are using an old version of the 3d library. If you do not want to update your installation, you need this fix.
    – user121799
    Jun 24, 2019 at 15:31

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .