1

This refers to the following link

Common label for a groupplot

I have applied this methodology for my group plots,it works well and is way less complex than the other solutions. The only issue I am having is that my y-axis label is a bit offset from the axis. (Extra gap highlighted by the ellipse).Not sure how to fix it.

Output

MWE:

\documentclass{standalone}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{pgfplots.groupplots}
\pgfplotsset{plot coordinates/math parser=false}
\usetikzlibrary{pgfplots.units}
\begin{document}
\sbox0{\includegraphics[width=4in]{example-image-a}}%
\sbox1{\includegraphics[width=4in]{example-image-a}}%
    \begin{tikzpicture}
        \begin{groupplot}[
            group style={
                group name=my plots,
                group size=1 by 2,
                xlabels at=edge bottom,
                xticklabels at=edge bottom,
                vertical sep=0pt
            },
            scale only axis, width={\wd0}, height={\ht0},
            ybar,
            footnotesize,
            width=5.4in,
            height=1in,  
            xlabel={Length($mm$)},
%           ylabel={Height($mm$)},
            xmin=0, xmax=10,
            ymin=0, ymax=0.6,
            xtick={0,1,...,10},
            xticklabels={0,1,...,10},
            ytick={0,0.2,...,0.6},
            yticklabels={0,0.2,0.4,0.6},
            tickpos=left,
            ytick align=outside,
            xtick align=outside
        ]
        \nextgroupplot
        \addplot graphics[xmin=0,ymin=0,xmax=10,ymax=0.6] {example-image-a};
        \nextgroupplot[ylabel=Height($mm$),
              every axis y label/.append style={at=(ticklabel cs:1.0)}]
        \addplot  graphics[xmin=0,ymin=0,xmax=10,ymax=0.6] {example-image-b};
        \end{groupplot}

    \end{tikzpicture}
\end{document}
2
  • What exactly do you mean by offset? Could you highlight the issue in a picture?
    – JulianWgs
    Commented Aug 18, 2017 at 19:51
  • The extra gap between the label and the axis as highlighted by the ellipse Commented Aug 18, 2017 at 19:57

1 Answer 1

0

enter image description here

Use [ylabel shift= ??] in the options for \nextgroupplot:

\documentclass{standalone}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{pgfplots.groupplots}
\pgfplotsset{plot coordinates/math parser=false}
\usetikzlibrary{pgfplots.units}
\begin{document}
\sbox0{\includegraphics[width=4in]{example-image-a}}%
\sbox1{\includegraphics[width=4in]{example-image-a}}%
    \begin{tikzpicture}
        \begin{groupplot}[
            group style={
                group name=my plots,
                group size=1 by 2,
                xlabels at=edge bottom,
                xticklabels at=edge bottom,
                vertical sep=0pt
            },
            scale only axis, width={\wd0}, height={\ht0},
            ybar,
            footnotesize,
            width=5.4in,
            height=1in,  
            xlabel={Length($mm$)},
%           ylabel={Height($mm$)},
            xmin=0, xmax=10,
            ymin=0, ymax=0.6,
            xtick={0,1,...,10},
            xticklabels={0,1,...,10},
            ytick={0,0.2,...,0.6},
            yticklabels={0,0.2,0.4,0.6},
            tickpos=left,
            ytick align=outside,
            xtick align=outside
        ]
        \nextgroupplot
        \addplot graphics[xmin=0,ymin=0,xmax=10,ymax=0.6] {example-image-a};
        \nextgroupplot[ylabel=Height($mm$),ylabel shift = -25 pt,
              every axis y label/.append style={at=(ticklabel cs:1.0)}]
        \addplot  graphics[xmin=0,ymin=0,xmax=10,ymax=0.6] {example-image-b};
        \end{groupplot}

    \end{tikzpicture}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .