[Tex/LaTex] Table and TikZ object on two columns

minipagetables

I'm trying to have a table generated by the tabular environment and a plot generated by TikZ placed side by side. I tried using the table and minipage environment since it works for having multiple tables side by side. However the two objects seems to be off vertically, what am I doing wrong?

\documentclass{article}
\usepackage{tikz}
\usepackage{amsmath}
\usepackage{gensymb}
\usepackage{pgfplots}

\begin{document}
\begin{table}
  \begin{minipage}[b]{5 cm}
  \centering
  \begin{tabular}{|c|c|}
   \hline                       
   Temperature & IQ Score \\ \hline
   14\celsius & 57\% \\ \hline
   16\celsius & 65\% \\ \hline
   18\celsius & 69\% \\ \hline
   20\celsius & 71\% \\ \hline
   22\celsius & 79\% \\ \hline
   24\celsius & 88\% \\ \hline
   26\celsius & 81\% \\ \hline
   28\celsius & 76\% \\ \hline
   30\celsius & 66\% \\ \hline
   32\celsius & 62\% \\ 
   \hline  
  \end{tabular}
  \end{minipage}
  \hspace{1cm} 
  \begin{minipage}[b]{10cm}
  \centering
   \begin{tikzpicture}
   \begin{axis}[grid=major, grid style={dashed,gray!30}, xlabel=Temperature $\celsius$,ylabel=IQ Scores \%, legend style={at={(axis cs:25,28)},anchor=south}]
   %\addplot[scatter, only marks, scatter/classes={y={black}}] table[x=x, y=y, col sep=comma] {NumbersAndFunctions-Temp-IQ-data.csv};
   \addplot[color=red, domain=7:41, thick, samples=400, mark=none] {88*exp(-(\x-24)^2/253.0889)};
   \legend{Raw, Gaussian};
   \end{axis}   
   \end{tikzpicture}
  \end{minipage}
\end{table}
\end{document}

enter image description here

Thanks

Best Answer

These are aligned at the top:

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{width=8cm}
\usepackage{siunitx}
\begin{document}
  \begin{table}
  \begin{minipage}[t]{5 cm}
  \centering
  \begin{tabular}[t]{|c|c|}
   \hline
   Temperature & IQ Score \\ \hline
   \SI{14}{\celsius} & \SI{57}{\percent} \\ \hline    %% change all \% like this
   \SI{16}{\celsius} & 65\% \\ \hline
   \SI{18}{\celsius} & 69\% \\ \hline
   \SI{20}{\celsius} & 71\% \\ \hline
   \SI{22}{\celsius} & 79\% \\ \hline
   \SI{24}{\celsius} & 88\% \\ \hline
   \SI{26}{\celsius} & 81\% \\ \hline
   \SI{28}{\celsius} & 76\% \\ \hline
   \SI{30}{\celsius} & 66\% \\ \hline
   \SI{32}{\celsius} & 62\% \\
   \hline
  \end{tabular}
  \end{minipage}
   \hfill
   \begin{tikzpicture}[baseline={(current bounding box.north)}]
   \begin{axis}[grid=major, grid style={dashed,gray!30}, xlabel=Temperature $\celsius$,ylabel=IQ Scores\si{\percent}, legend style={at={(axis cs:25,28)},anchor=south}]
   %\addplot[scatter, only marks, scatter/classes={y={black}}] table[x=x, y=y, col sep=comma] {NumbersAndFunctions-Temp-IQ-data.csv};
   \addplot[color=red, domain=7:41, thick, samples=400, mark=none] {88*exp(-(\x-24)²/253.0889)};
   \addlegendentry{Raw,Gaussian};
   \end{axis}
   \end{tikzpicture}
\end{table}
\end{document}

enter image description here

With no [t] in minipage and [baseline={(current bounding box.center)}] in tikzpicture they are aligned at the center.

enter image description here

With no [b] in both tabular and minipage and [baseline={(current bounding box.south)}] in tikzpicture they are aligned at the bottom.

enter image description here