1

Is it possible to put a graph and a table together in one figure?

\usepackage{subcaption}

\begin{figure}[b]
    \centering
    \includegraphics[width=0.4\linewidth]{Fit3Dir_30min/ModelSelectionGraphs/Histogram_smad7_reproduced_AICc}
    \begin{tabular}{c|c|c|c}
        Model Selection Criteria & Model 1 & Model 2 & Model 3\\
        \hline
        RSS  & 614.037  & 615.003 & 698.592\\
        AICc & 234.751  & 234.996 & 254.877\\
        BIC  & 264.25   & 264.495 & 284.376\\

    \end{tabular}
    \caption{Distribution of corrected Akaike information criteria (AICc) per model}
    \label{fig:model_selection}
\end{figure}

This code produces : enter image description here

which is only half way there. I would like to be able to add a separate caption and label to both the table and graph since they are separate things but still belong in one figure.

I have tried wrapping the table and graph parts of the figure in subfigure environment but it did not work and I have seen a few other posts such as this which also has not solved my problem.

I'm looking for the simplest solution preferably using the subcaption package since this is what I'm using for the rest of my figures.

Thanks in advance

  • I think a minipage with a figure and table inside is the way to go, but I'm not sure. – Thorbjørn E. K. Christensen Dec 20 '17 at 10:52
  • Cool. I'll have a google – CiaranWelsh Dec 20 '17 at 10:52
  • Would you like them put side by side or one below the other? In other word, horizontal or vertical aligned? – Cragfelt Dec 20 '17 at 10:57
1

If you want to place the table below the picture, you can use the subfig package (as in the link you posted), like this

enter image description here

\documentclass{article}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{subfig}


\begin{document}

\begin{figure}[!htbp]
    \centering
    \subfloat[][]{%
        \includegraphics[width=.4\linewidth]{example-image}
    }%
    \vfill
    \subfloat[][]{%
    \begin{tabular}{c|c|c|c}
        Model Selection Criteria & Model 1 & Model 2 & Model 3\\
        \hline
        RSS  & 614.037  & 615.003 & 698.592\\
        AICc & 234.751  & 234.996 & 254.877\\
        BIC  & 264.25   & 264.495 & 284.376\\
        \hline
    \end{tabular}
    }
    \caption{Distribution of corrected Akaike information criteria (AICc) per model}
    \label{fig:model_selection}
\end{figure}

\end{document}
2
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{array}
\usepackage{caption}
\begin{document}

\begin{figure}[b]
\centering
\begin{minipage}[t]{0.4\linewidth}\vspace{0pt}
\includegraphics[width=\linewidth]{Fit3Dir_30min/ModelSelectionGraphs/Histogram_smad7_reproduced_AICc}
\caption{Distribution of corrected Akaike information criteria (AICc) per model}
\label{fig:model_selection}
\end{minipage}
\hfill
\begin{minipage}[t]{0.57\linewidth}
\captionof{table}{A tabular caption}
\resizebox{\linewidth}{!}{%
\begin{tabular}{c|c|c|c}
        Model Selection Criteria & Model 1 & Model 2 & Model 3\\\hline
        RSS  & 614.037  & 615.003 & 698.592\\
        AICc & 234.751  & 234.996 & 254.877\\
        BIC  & 264.25   & 264.495 & 284.376\\
\end{tabular}}
\end{minipage}
\end{figure}    

\end{document}

enter image description here

  • Hi Herbert, thanks for the post. Would you happen to know how to get the table below the figure, rather than side by side? – CiaranWelsh Dec 20 '17 at 11:21
  • Actually, I've figured out I can replace \hfill with \vfill. However there is one last problem - I need the Figure 1 part to be part A of the figure the table to be part B. Then Id like one overall caption for the whole figure at the bottom. Thanks again. – CiaranWelsh Dec 20 '17 at 11:28
  • 1
    then you do not need minipages and let only one empty line between image and tabular. That's all – user2478 Dec 20 '17 at 14:31

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.