[Tex/LaTex] Tikz: Reposition Legend (\node) next to Drawing (\draw)

tikz-pgf

I want to make the "Legend" appear on the right hand side of the drawing…Any suggestions? I tried playing around with the anchoring direction and slope to no avail.

 \documentclass[tikz,border=10pt]{standalone}
    \usepackage{amssymb}
    \usetikzlibrary{positioning}
    \begin{document}

    \begin{center}
      \begin{tikzpicture}
        \foreach \x/\y/\z in {1/1/9,3.2/1/10,2/1.5/8,1.5/2/6, 2.5/2/7,1.2/2.5/2,2/2.5/4,3.1/2.5/5,2/3/1,2.9/2.9/3}{
        \node[circle,fill,inner sep=1.5pt,outer sep=0pt,label={[xshift=-3pt,yshift=2pt,scale=0.7]-60:$\mathrm{P}_{\z}$}] (\z) at (\x,\y){};
        }
        \node[draw,rectangle,anchor=south west,minimum width=4cm,minimum height=4cm] (A) at (0,0) {};
        \node[draw,rectangle,top color=white,bottom color=gray!60,anchor=south west,minimum width=4cm,minimum height=4cm] (B) at (1.3,5) {};
        \draw (A.north west) -- (B.north west)
              (A.north east) -- (B.north east)
              (A.south west) -- (B.south west)
              (A.south east) -- (B.south east);
        \node (U) at (-1,5) {$\mathrm{U}_1$};
        \node at (-1,2) {$\mathrm{U}_2$};
        \draw (U.east) edge[bend left] (1.west);
        \draw (U.east) edge[bend right] (2.south);
        \node[anchor=west] at (0,-1) {Legend:};
        \node[anchor=west] at (0,-1.5) {{\tiny$\blacksquare$} $\mathrm{U}_1$ - instantiated universal};
        \node[anchor=west] at (0,-2) {{\tiny$\blacksquare$} $\mathrm{U}_2$ - uninstantiated universal};
        \node[anchor=west] at (0,-2.5) {{\tiny$\blacksquare$} $\mathrm{P}_1 \ldots \mathrm{P}_2$ - thin particulars};
        \node[anchor=west] at (0,-3) {{\tiny$\blacksquare$} $\mathrm{P}_3 \ldots \mathrm{P}_{10}$ - bare particulars};
        \node[anchor=center,above = 0.1cm of B.north west,font=\bfseries\large] {Space-time manifold}; 

    \end{tikzpicture}
    \end{center}

    \end{document}

Best Answer

Would this be close to what you need? Use of scope environment wrapping your legend in side and apply [shift={(xx,yy)}] to suit your needs for the locations. Furthermore, for the title manifold, you can use xshift=xx to move it to the right.

enter image description here

Code

\documentclass[tikz,border=10pt]{standalone}
    \usepackage{amssymb}
    \usetikzlibrary{positioning}
    \begin{document}

    \begin{center}
      \begin{tikzpicture}
        \foreach \x/\y/\z in {1/1/9,3.2/1/10,2/1.5/8,1.5/2/6, 2.5/2/7,1.2/2.5/2,2/2.5/4,3.1/2.5/5,2/3/1,2.9/2.9/3}{
        \node[circle,fill,inner sep=1.5pt,outer sep=0pt,label={[xshift=-3pt,yshift=2pt,scale=0.7]-60:$\mathrm{P}_{\z}$}] (\z) at (\x,\y){};
        }
        \node[draw,rectangle,anchor=south west,minimum width=4cm,minimum height=4cm] (A) at (0,0) {};
        \node[draw,rectangle,top color=white,bottom color=gray!60,anchor=south west,minimum width=4cm,minimum height=4cm] (B) at (1.3,5) {};
        \draw (A.north west) -- (B.north west)
              (A.north east) -- (B.north east)
              (A.south west) -- (B.south west)
              (A.south east) -- (B.south east);
        \node (U) at (-1,5) {$\mathrm{U}_1$};
        \node at (-1,2) {$\mathrm{U}_2$};
\begin{scope}[shift={(6cm,5cm)}]
        \draw (U.east) edge[bend left] (1.west);
        \draw (U.east) edge[bend right] (2.south);
        \node[anchor=west] at (0,-1) {Legend:};
        \node[anchor=west] at (0,-1.5) {{\tiny$\blacksquare$} $\mathrm{U}_1$ - instantiated universal};
        \node[anchor=west] at (0,-2) {{\tiny$\blacksquare$} $\mathrm{U}_2$ - uninstantiated universal};
        \node[anchor=west] at (0,-2.5) {{\tiny$\blacksquare$} $\mathrm{P}_1 \ldots \mathrm{P}_2$ - thin particulars};
        \node[anchor=west] at (0,-3) {{\tiny$\blacksquare$} $\mathrm{P}_3 \ldots \mathrm{P}_{10}$ - bare particulars};
\end{scope}
        \node[anchor=center,above = 0.1cm of B.north west,font=\bfseries\large, xshift=1cm] {Space-time manifold}; 
    \end{tikzpicture}
    \end{center}

    \end{document}