2

I would like to align the plot shown in the picture below to the top, so that it is aligned with the "smile"-pictures next to it. I tried out different things, but nothing worked out. Maybe you have an idea how the alignment would work? What I have tried out:

  • \begin{tikzpicture}[baseline={([yshift={-\ht\strutbox}]current bounding box.north)}]....
  • use "p" instead of "m" in the tabular environment
  • vary the tikzpicture height
  • try to avoid multirow, but I was not able to find another way to organize the graph and the six pictures including the numbering nicely - but maybe you know another way?

Thanks a lot for your help! Simone

Here is the code:

\documentclass[
twoside,openright,titlepage,numbers=noenddot,headinclude,
footinclude=true,cleardoublepage=empty,
dottedtoc, 
BCOR=5mm,paper=a4,fontsize=11pt, 
ngerman,american, 
floatperchapter, 
]{scrreprt} 

\usepackage{tikz,pgfplots}
\usepackage{calc}
\usepackage{multirow}
\usepackage{tabularx}
\usepackage{graphicx}

\begin{document}
    
\begin{figure}[bth]
    \small
    \centering
    \noindent\begin{tabular}{m{6.0cm}m{0.1cm}m{1.8cm}m{0.1cm}m{1.8cm}}
        {(a)} & {(b)} &  & & \\
        \multirow{3}{*}{
            \begin{tikzpicture}[font=\small]
                \begin{axis}[
                    width=6cm,
                    height=6.8cm,               
                    xmin=800,xmax=990, 
                    scaled ticks=false, 
                    xticklabel style={/pgf/number format/.cd,fixed,zerofill,precision=0,use comma},
                    xtick={850,900,950}, 
                    ymin=0,ymax=0.14, 
                    yticklabel style={/pgf/number format/.cd,fixed,zerofill,precision=2,use comma},
                    ytick={0.04,0.12}, 
                    xlabel={Data x values},
                    ylabel={Data y values},
                    ]
                    \addplot+ [
                    sharp plot,only marks,
                    ]
                    coordinates {
                        (956.7818,0.0207)
                        (906.6738,0.0075)
                        (891.8467,0.0039)
                        (933.3216,0.2029)
                        (832.1925,0.4017)
                        (945.5146,0.2317)
                        (947.2539,0.0414)
                        (880.3353,0.1197)
                        (863.7405,0.0711)
                        (853.8516,0.0338)
                        (884.8370,0.0013)
                        (910.5405,0.0461)};
                \end{axis}          
            \end{tikzpicture}
        }
        & 
        (1) & \includegraphics[width=1.8cm]{smile.jpg} & 
        (2) &  \includegraphics[width=1.8cm]{smile.jpg} \\
        & 
        (3) & \includegraphics[width=1.8cm]{smile.jpg} & 
        (4) &  \includegraphics[width=1.8cm]{smile.jpg} \\
        & 
        (5) & \includegraphics[width=1.8cm]{smile.jpg} & 
        (6) &  \includegraphics[width=1.8cm]{smile.jpg} \\
    \end{tabular}
\end{figure}

\end{document}

And this is how it looks at the moment: enter image description here

2
  • Why did you use a tabular in the first place? Two side by side minipages or two subfigures should also work here.
    – leandriis
    Jan 20, 2021 at 10:27
  • \multirow{-2}{*}{ should make the plot shift upwards -- you can experiment with other numbers including decimals such as 2.1 ......
    – js bibra
    Jan 20, 2021 at 10:36

2 Answers 2

2

Edit:

  • With use of two ties top aligned tables, where in the first diagram is manually moved down for amount determined by trial.
  • Images in the second table have moved their baselines to their vertical center by use of the adjust package`:
\documentclass[
twoside,openright,titlepage,numbers=noenddot,headinclude,
footinclude=true,cleardoublepage=empty,
dottedtoc,
BCOR=5mm,paper=a4,fontsize=11pt,
ngerman,american,
floatperchapter,
]{scrreprt}

\usepackage{pgfplots}
\pgfplotsset{compat=1.17}
%\usepackage{calc}
\usepackage{multirow, tabularx}
\usepackage[export]{adjustbox}    % it load graphicx too

\begin{document}
    \begin{figure}[htb]
    \small
    \centering
    \adjustboxset{height=19mm,valign=c, margin=0pt 3pt 0pt 3pt}
\begin{tabular}[t]{l}
    (a)     \\[4ex]
    \begin{tikzpicture}
\begin{axis}[font=\small,
    width=6cm,
    height=6.8cm,
    xmin=800,xmax=990,
    xtick={850,900,950},
    ymin=0, ymax=0.14,
    yticklabel style={/pgf/number format/.cd,fixed,zerofill,precision=2,use comma},
    ytick={0.04,0.12},
    xlabel={Data x values},
    ylabel={Data y values},
    ]
    \addplot+ [sharp plot,only marks]   coordinates {
        (956.7818,0.0207)
        (906.6738,0.0075)
        (891.8467,0.0039)
        (933.3216,0.2029)
        (832.1925,0.4017)
        (945.5146,0.2317)
        (947.2539,0.0414)
        (880.3353,0.1197)
        (863.7405,0.0711)
        (853.8516,0.0338)
        (884.8370,0.0013)
        (910.5405,0.0461)};
\end{axis}
    \end{tikzpicture}
\end{tabular}\begin{tabular}[t]{*{4}{l}}
    (b) &&& \\
    (1) & \adjustimage{}{example-image-duck}%{smile.jpg}
        &   (2) & \adjustimage{}{example-image-duck}%{smile.jpg}
        \\
    (3) & \adjustimage{}{example-image-duck}%{smile.jpg}
        &   (4) & \adjustimage{}{example-image-duck}%{smile.jpg}
        \\
    (5) & \adjustimage{}{example-image-duck}%{smile.jpg}
        &   (6) & \adjustimage{}{example-image-duck}%{smile.jpg}
\end{tabular}
    \end{figure}
\end{document}

Note: diagram is higher as your images of smileys (you should tell us, where are available) therefore in MWE is prescribed their height (19 mm), which together give an approximate height of the diagram.

enter image description here

3
  • Thank you very much for your answer! Could you explain me again why the diagram is higher than the images? And what can I do to have the upper border of the diagram aligned with the top of the upper images?
    – Simone
    Jan 20, 2021 at 15:46
  • @Simone, to have balanced position of images and diagram, thair height should be approximately equal. Since we haven't your original image, their height is unknown to us, in the my answer is used example-image.duck which at given width are not suficient height. In the case, that you use one table instead two (as is in edited answer), diagram spill out of table. T
    – Zarko
    Jan 20, 2021 at 16:07
  • Ah okay, thank you very much for the explanation Zarko!
    – Simone
    Jan 20, 2021 at 17:09
1

use

    \multirow{-2}{*}{

to get the plot shift upwards

enter image description here

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.