5

I'm working in a tikz figure that so far is like that:

enter image description here

Produced with the following code:

\documentclass[tikz,border=9]{standalone}
\usetikzlibrary{matrix, calc, backgrounds, decorations.pathreplacing}

\begin{document}

\tikzset{
    blur/.style={preaction={draw,fill,white,opacity=.9,line width=2pt}},
    showdepth/.style={color=#1,ball color=#1,opacity=1+(\k-2)/5},
    edgemeta/.is choice,
    edgemeta/1/.style={blur,showdepth=green},
    edgemeta/2/.style={blur,showdepth=yellow},
    nodemeta/.is choice,
    nodemeta/0/.style={blur,showdepth=blue},
    nodemeta/1/.style={blur,showdepth=green},
    nodemeta/2/.style={blur,showdepth=yellow},
    drawedge_i/.style={drawedgex_i,drawedgey_i,drawedgez_i},
    % Input volume    
    drawedgex_i/.code={
        \ifnum\i=2\else
            \pgfmathparse{int(max(abs(\i),abs(\i+1),abs(\j),abs(\k)))}
            \draw[edgemeta=\pgfmathresult](\i,\j,\k)--+(1,0,0);
        \fi
    },
    drawedgey_i/.code={
        \ifnum\j=2\else
            \pgfmathparse{int(max(abs(\i),abs(\j),abs(\j+1),abs(\k)))}
            \draw[edgemeta=\pgfmathresult](\i,\j,\k)--+(0,1,0);
        \fi
    },
    drawedgez_i/.code={
        \ifnum\k=2\else
            \pgfmathparse{int(max(abs(\i),abs(\j),abs(\k),abs(\k+1)))}
            \draw[edgemeta=\pgfmathresult](\i,\j,\k)--+(0,0,1);
        \fi
    },
    % Sublume
    drawedge_s/.style={drawedgex_s,drawedgey_s,drawedgez_s},
    drawedgex_s/.code={
        \ifnum\i=1\else
            \pgfmathparse{int(max(abs(\i),abs(\i+1),abs(\j),abs(\k)))}
            \draw[edgemeta=\pgfmathresult](\i,\j,\k)--+(1,0,0);
        \fi
    },
    drawedgey_s/.code={
        \ifnum\j=1\else
            \pgfmathparse{int(max(abs(\i),abs(\j),abs(\j+1),abs(\k)))}
            \draw[edgemeta=\pgfmathresult](\i,\j,\k)--+(0,1,0);
        \fi
    },
    drawedgez_s/.code={
        \ifnum\k=1\else
            \pgfmathparse{int(max(abs(\i),abs(\j),abs(\k),abs(\k+1)))}
            \draw[edgemeta=\pgfmathresult](\i,\j,\k)--+(0,0,1);
        \fi
    },
    % Node
    drawnode/.code={
        \pgfmathparse{int(max(abs(\i),abs(\j),abs(\k)))}
        \shade[nodemeta=\pgfmathresult](\i,\j,\k)circle(3pt);
    }
}
\begin{tikzpicture}[z={(-.3,-.15)},draw=white,decoration={brace,amplitude=10}]
    \begin{scope}
            \foreach\k in{-2,...,2}{
                \foreach\j in{-2,...,2}{
                    \foreach\i in{-2,...,2}{
                        \path[drawedge_i,drawnode];
                    }
                }
        } 
        \coordinate (A) at (1,1,0); \coordinate (B) at (1,-1,0);
        \draw [decorate, red, thick] (A.north east) -- (B.south east);
    \end{scope}

    \begin{scope}[xshift=5cm]
            \foreach\k in{-1,...,1}{
                \foreach\j in{-1,...,1}{
                    \foreach\i in{-1,...,1}{
                        \path[drawedge_s,drawnode];
                    }
                }
        }
    \end{scope}

    \begin{scope}[xshift=9cm]
            \foreach\k in{-1,...,1}{
                \foreach\j in{-1,...,1}{
                    \foreach\i in{-1,...,1}{
                        \path[drawedge_s,drawnode];
                    }
                }
        }
    \end{scope}

\end{tikzpicture}

\end{document}

I'm wondering how I could change the 'width' of the brace so it reaches the second image, or how to draw an arrow from it to connect these scopes, as here:

enter image description here

Also, I'm wondering how to connect to scopes with an arrow, as:

enter image description here

In this image, I used \matrix(name), so I could simply do:

\draw [red, -latex, thick](A) -- (B)

For example.

Using scopes, I tried to do:

\begin{scope}[name=A]
\end{scope}

\begin{scope}[name=B]
\end{scope}

\draw [red, -latex, thick](A) -- (B)

But I receive an error warning me that no shape with that names were found.

Thank you in advance.

3

You have already learnt how to define nodes while drawing the brace. Define some more of them and draw.

\documentclass[tikz,border=9]{standalone}
\usetikzlibrary{matrix, calc, backgrounds, decorations.pathreplacing}

\begin{document}

\tikzset{
    blur/.style={preaction={draw,fill,white,opacity=.9,line width=2pt}},
    showdepth/.style={color=#1,ball color=#1,opacity=1+(\k-2)/5},
    edgemeta/.is choice,
    edgemeta/1/.style={blur,showdepth=green},
    edgemeta/2/.style={blur,showdepth=yellow},
    nodemeta/.is choice,
    nodemeta/0/.style={blur,showdepth=blue},
    nodemeta/1/.style={blur,showdepth=green},
    nodemeta/2/.style={blur,showdepth=yellow},
    drawedge_i/.style={drawedgex_i,drawedgey_i,drawedgez_i},
    % Input volume
    drawedgex_i/.code={
        \ifnum\i=2\else
            \pgfmathparse{int(max(abs(\i),abs(\i+1),abs(\j),abs(\k)))}
            \draw[edgemeta=\pgfmathresult](\i,\j,\k)--+(1,0,0);
        \fi
    },
    drawedgey_i/.code={
        \ifnum\j=2\else
            \pgfmathparse{int(max(abs(\i),abs(\j),abs(\j+1),abs(\k)))}
            \draw[edgemeta=\pgfmathresult](\i,\j,\k)--+(0,1,0);
        \fi
    },
    drawedgez_i/.code={
        \ifnum\k=2\else
            \pgfmathparse{int(max(abs(\i),abs(\j),abs(\k),abs(\k+1)))}
            \draw[edgemeta=\pgfmathresult](\i,\j,\k)--+(0,0,1);
        \fi
    },
    % Sublume
    drawedge_s/.style={drawedgex_s,drawedgey_s,drawedgez_s},
    drawedgex_s/.code={
        \ifnum\i=1\else
            \pgfmathparse{int(max(abs(\i),abs(\i+1),abs(\j),abs(\k)))}
            \draw[edgemeta=\pgfmathresult](\i,\j,\k)--+(1,0,0);
        \fi
    },
    drawedgey_s/.code={
        \ifnum\j=1\else
            \pgfmathparse{int(max(abs(\i),abs(\j),abs(\j+1),abs(\k)))}
            \draw[edgemeta=\pgfmathresult](\i,\j,\k)--+(0,1,0);
        \fi
    },
    drawedgez_s/.code={
        \ifnum\k=1\else
            \pgfmathparse{int(max(abs(\i),abs(\j),abs(\k),abs(\k+1)))}
            \draw[edgemeta=\pgfmathresult](\i,\j,\k)--+(0,0,1);
        \fi
    },
    % Node
    drawnode/.code={
        \pgfmathparse{int(max(abs(\i),abs(\j),abs(\k)))}
        \shade[nodemeta=\pgfmathresult](\i,\j,\k)circle(3pt);
    },
    mydeco/.style={decoration={brace,amplitude=#1},decorate}
}
\begin{tikzpicture}[z={(-.3,-.15)},draw=white]
    \begin{scope}
            \foreach\k in{-2,...,2}{
                \foreach\j in{-2,...,2}{
                    \foreach\i in{-2,...,2}{
                        \path[drawedge_i,drawnode];
                    }
                }
        }
        \coordinate (A) at (1,1,0); \coordinate (B) at (1,-1,0);
        \draw [mydeco={10}, red, thick] (A.north east) -- (B.south east)node[coordinate,midway,right](C){};
    \end{scope}

    \begin{scope}[xshift=5cm]
            \foreach\k in{-1,...,1}{
                \foreach\j in{-1,...,1}{
                    \foreach\i in{-1,...,1}{
                        \path[drawedge_s,drawnode];
                    }
                }
        }
        \coordinate (D) at (-1,0,0);
        \draw[red,-latex,shorten >= 5pt,shorten <= 10pt] (C) -- (D);
        \coordinate (E) at (1,1,0); \coordinate (F) at (1,-1,0);
        \draw [mydeco={10}, red, thick] (E.north east) -- (F.south east)node[coordinate,midway,right](G){};
    \end{scope}

    \begin{scope}[xshift=9cm]
            \foreach\k in{-1,...,1}{
                \foreach\j in{-1,...,1}{
                    \foreach\i in{-1,...,1}{
                        \path[drawedge_s,drawnode];
                    }
                }
        }
        \coordinate (H) at (-1,0,0);
        \draw[red,-latex,shorten >= 5pt,shorten <= 10pt] (G) -- (H);
    \end{scope}

\end{tikzpicture}

\end{document}

enter image description here

Just make sure that the dimension (10 here) in mydeco={10} and shorten <= 10pt are same.

|improve this answer|||||
  • Yeah, that was what I did yesterday after some reserach; I was wondering if I could connect the scopes in a 'magic' way as we can do when using \matrix. Thank you. – pceccon Mar 15 '15 at 12:53

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.