# Add plot to node in Tikz matrix

Using the code at the end, I was able to create this image.

I would like to add a plot (I'm plotting kernel densities) to each of the nodes on the edge, and move their labels below the plot, such that the plot and label are the same height as the center box.

This would mean, on the left would be a plot with y below the x-axis and on the right would be a plot with u below the x-axis.

Is this possible to do with the matrix structure, and if not, is there an alternate way to create this?

\documentclass[tikz,border=2]{standalone}

\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{shapes,snakes,calc}
\tikzstyle{connector} = [->,thick]

\begin{document}

\begin{tikzpicture}[x=3in,y=2in]
\tikzstyle{ann} = [draw=none,fill=none,right]
\matrix[nodes={draw, thick, fill=none},
row sep=0.3cm,column sep=0.5cm] {
\node[draw=none,fill=none] (N1) {$\mathbf{y}$}; &
\node[rectangle, minimum height=0.5in, minimum width = 0.75in] (N2) {Center}; &
\node[draw=none] (N3) {$\mathbf{u}$};\\
};

\draw [connector] (N1) -- node {} (N2);
\draw [connector] (N2) -- node {} (N3);
\end{tikzpicture}

\end{document}


Yes, this can be done (see example below). However, it's not clear that you really need a matrix here since all the required elements can be arranged as desired without using a matrix.

One option would be to use pgfplots to draw your plots; box them (a precaution to avoid the plots from inheriting settings from the "outer" tikzpicture) and then use the boxes in the \nodes of your matrix:

The code:

\documentclass[tikz,border=2]{standalone}
\usepackage{amsmath}
\usepackage{pgfplots}
\usetikzlibrary{shapes,snakes,calc}
\tikzstyle{connector} = [->,thick]

\newsavebox\myboxa
\newsavebox\myboxb
\savebox\myboxa{%
\begin{tikzpicture}
\begin{axis}[
axis lines=middle,
width=4cm,
]
\end{axis}
\end{tikzpicture}%
}
\savebox\myboxb{%
\begin{tikzpicture}
\begin{axis}[
axis lines=middle,
width=4cm
]
\end{axis}
\end{tikzpicture}%
}

\begin{document}

\begin{tikzpicture}[x=3in,y=2in]
\tikzstyle{ann} = [draw=none,fill=none,right]
\matrix[nodes={draw, thick, fill=none},
row sep=0.3cm,column sep=0.5cm] {
\node[draw=none,fill=none,label={below:$\mathbf{u}$}] (N1) {\usebox\myboxa}; &
\node[rectangle, minimum height=0.5in, minimum width = 0.75in] (N2) {Center}; &
\node[draw=none,label={below:$\mathbf{y}$}] (N3) {\usebox\myboxb};\\
};

\draw [connector] (N1) -- node {} (N2);
\draw [connector] (N2) -- node {} (N3);
\end{tikzpicture}

\end{document}