I have a tikz figure in which a table is embedded within the horizontal lines drawn in the figure. I need to adjust the rows of the table according to the figure placement. I tried adjust the table spacing manually but it does not produce a consistent result. Only the last row is somehow aligned. The first entry (y, y_n) is off by a row. Any help regarding how this can be achieved will be appreciated.
MWE
\documentclass[10pt]{article}
\usepackage{tikz}
\usepackage{tabularx}
\usepackage{booktabs}
\pagestyle{empty}
\begin{document}
\begin{tikzpicture}[line cap=round,line join=round]
\draw [ultra thick] (-6.,2.)-- (-6.,1.);
\draw [ultra thick] (-6.,2.)-- (-4.,2.);
\draw [ultra thick] (-4.,1.)-- (-4.,4.);
\draw [ultra thick] (0.,7.)-- (0.,1.);
\draw [ultra thick] (-2.,3.)-- (-2.,1.);
\draw [ultra thick] (3.,5.)-- (3.,1.);
\draw [ultra thick] (5.,3.)-- (5.,1.);
\draw [ultra thick] (1.,2.)-- (0.,2.);
\draw [ultra thick] (3.,5.)-- (0.,5.);
\draw [ultra thick] (-4.,4.)-- (0.,4.);
\draw [ultra thick] (-4.,1.)-- (-5.,1.);
\draw [ultra thick] (-2.,1.)-- (-3.,1.);
\draw [ultra thick] (-2.,3.)-- (0.,3.);
\draw [ultra thick] (0.,1.)-- (-1.,1.);
\draw [ultra thick] (1.,2.)-- (1.,1.);
\draw [ultra thick] (3.,1.)-- (2.,1.);
\draw [ultra thick] (3.,2.)-- (4.,2.);
\draw [ultra thick] (4.,2.)-- (4.,1.);
\draw [ultra thick] (5.,1.)-- (6.,1.);
\draw [ultra thick] (5.,3.)-- (3.,3.);
\draw [gray] (-6.5,0.5)-- (9,0.5);
\draw [gray] (-6.5,1.5)-- (9,1.5);
\draw [gray] (-6.5,2.5)-- (9,2.5);
\draw [gray] (-6.5,3.5)-- (9,3.5);
\draw [gray] (-6.5,4.5)-- (9,4.5);
\draw [gray] (-6.5,5.5)-- (9,5.5);
\draw [gray] (-6.5,6.5)-- (9,6.5);
\draw [gray] (-6.5,7.5)-- (9,7.5);
\draw [gray] (-6.5,8.5)-- (9,8.5);
\draw node (-3,-.25) {Symbol \tikz \fill [] circle (0.25cm); denotes one pair of rabbits.};
\fill [] (0.,7.) circle (0.25cm);
\fill [] (0.,6.) circle (0.25cm);
\fill [] (0.,5.) circle (0.25cm);
\fill [] (0.,4.) circle (0.25cm);
\fill [] (0.,3.) circle (0.25cm);
\fill [] (0.,2.) circle (0.25cm);
\fill [] (0.,1.) circle (0.25cm);
\fill [] (-1.,1.) circle (0.25cm);
\fill [] (-2.,1.) circle (0.25cm);
\fill [] (-3.,1.) circle (0.25cm);
\fill [] (-4.,1.) circle (0.25cm);
\fill [] (-5.,1.) circle (0.25cm);
\fill [] (-6.,1.) circle (0.25cm);
\fill [] (-6.,2.) circle (0.25cm);
\fill [] (-4.,2.) circle (0.25cm);
\fill [] (-4.,3.) circle (0.25cm);
\fill [] (-4.,4.) circle (0.25cm);
\fill [] (-2.,3.) circle (0.25cm);
\fill [] (-2.,2.) circle (0.25cm);
\fill [] (1.,2.) circle (0.25cm);
\fill [] (1.,1.) circle (0.25cm);
\fill [] (2.,1.) circle (0.25cm);
\fill [] (3.,1.) circle (0.25cm);
\fill [] (3.,2.) circle (0.25cm);
\fill [] (3.,3.) circle (0.25cm);
\fill [] (3.,4.) circle (0.25cm);
\fill [] (3.,5.) circle (0.25cm);
\fill [] (4.,2.) circle (0.25cm);
\fill [] (4.,1.) circle (0.25cm);
\fill [] (5.,1.) circle (0.25cm);
\fill [] (5.,2.) circle (0.25cm);
\fill [] (5.,3.) circle (0.25cm);
\fill [] (6.,1.) circle (0.25cm);
\node (tbl) at (9,4.5){
\begin{tabularx}{.2\textwidth}{cc}
$n $ & $y_{n}$ \[20pt]
1 & 1 \[20pt]
2 & 1 \[20pt]
3 & 2 \[20pt]
4 & 3 \[20pt]
5 & 5 \[20pt]
6 & 8 \[20pt]
7 & 13 \[20pt]
\end{tabularx}};
\end{tikzpicture}
\end{document}




tabularxnode with something like\node(tbl0) at (8.5,8){$n $ \quad $y_{n}$}; \node(tbl1) at (8.5,7){1 \quad 1}; \node(tbl2) at (8.5,6){2 \quad 1}; \node(tbl3) at (8.5,5){3 \quad 2}; \node(tbl4) at (8.5,4){4 \quad 3}; \node(tbl5) at (8.5,3){5 \quad 5}; \node(tbl6) at (8.5,2){6 \quad 8}; \node(tbl7) at (8.5,1){7 \quad 13};. – leandriis Aug 08 '20 at 12:03