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

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

  • When I compile this I get the following image, imgur.com/a/BTVZgDF, do you know what the problem is? – rodger_kicks Jun 24 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. – marmot Jun 24 at 15:31

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.