1

I want to have multiple y labels in a group plot. Now I have 4 different values for ylabels:Range1, Range2, Range3 and Range4. I want to add a common ylabel say "throughput". How do I do that?

\documentclass{standalone}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{pgfplots}
\usepgfplotslibrary{groupplots}
\pgfplotsset{compat=newest}
\begin{document}

\begin{tikzpicture}
    \begin{groupplot}[group style={group size= 2 by 4},height=5cm,width=6.4cm]
        \nextgroupplot[title=type1,ylabel={Range1 },symbolic x coords={1,2,4,8,16,32,64,128},xtick=data]
                \addplot[blue] table{Data/test.dat};
        \nextgroupplot[title=type2,symbolic x coords={1,2,4,8,16,32,64,128},xtick=data]
                \addplot[blue] table{Data/test.dat};
        \nextgroupplot[ylabel={Range2 },symbolic x coords={1,2,4,8,16,32,64,128},xtick=data]
                \addplot[blue] table{Data/test.dat};
        \nextgroupplot[symbolic x coords={1,2,4,8,16,32,64,128},xtick=data]
                \addplot[blue] table{Data/test.dat};
        \nextgroupplot[ylabel={Range3 },symbolic x coords={1,2,4,8,16,32,64,128},xtick=data]
                \addplot[blue] table{Data/test.dat};
        \nextgroupplot[symbolic x coords={1,2,4,8,16,32,64,128},xtick=data]
                \addplot[blue] table{Data/test.dat};
        \nextgroupplot[xlabel={Number of Threads},ylabel={Range4 },symbolic x coords={1,2,4,8,16,32,64,128},xtick=data]
                \addplot[blue] table{Data/test.dat};
        \nextgroupplot[xlabel={Number of Threads},symbolic x coords={1,2,4,8,16,32,64,128},xtick=data]
                \addplot[blue] table{Data/test.dat};
    \end{groupplot}
\end{tikzpicture}

\end{document}

output

arunmoezhi
  • 1,270

1 Answers1

2

Update:

You can name the group using the group name option and then refer each single group plot:

\documentclass[margin=5mm]{standalone}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{pgfplots}
\usepgfplotslibrary{groupplots}
\pgfplotsset{compat=newest}
\begin{document}

\begin{tikzpicture}
    \begin{groupplot}[group style={
                        group name=myplot,% <- name the group plot
                        group size= 2 by 4},height=5cm,width=6.4cm]
        \nextgroupplot[title=type1,ylabel={Range1 }]
                \addplot[blue] {x};
        \nextgroupplot[title=type2]
                \addplot[blue]{x};
        \nextgroupplot[ylabel={Range2 }]
                \addplot[blue]{x};
        \nextgroupplot
                \addplot[blue]{x};
        \nextgroupplot[ylabel={Range3 }]
                \addplot[blue]{x};
        \nextgroupplot
                \addplot[blue]{x};
        \nextgroupplot[xlabel={Number of Threads},ylabel={Range4 }]
                \addplot[blue]{x};
        \nextgroupplot[xlabel={Number of Threads}]
                \addplot[blue]{x};
    \end{groupplot}
    \path (myplot c1r1.outer north west)% plot in column 1 row 1
          -- node[anchor=south,rotate=90] {throughput}% label midway
          (myplot c1r4.outer south west)% plot in column 1 row 4
    ;
\end{tikzpicture}

\end{document}

enter image description here


Original answer:

You can define one coordinate on top of the first plot and one on the bottom of the last plot. Then you can position the label vertical centered between this two coordinates on the left border of the current bounding box.

\documentclass[margin=5mm]{standalone}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{pgfplots}
\usepgfplotslibrary{groupplots}
\pgfplotsset{compat=newest}
\begin{document}

\begin{tikzpicture}
    \begin{groupplot}[group style={group size= 2 by 4},height=5cm,width=6.4cm]
        \nextgroupplot[title=type1,ylabel={Range1 }]
                \addplot[blue] {x};
                \coordinate (top) at (rel axis cs:0,1);% coordinate at top of the first plot
        \nextgroupplot[title=type2]
                \addplot[blue]{x};
        \nextgroupplot[ylabel={Range2 }]
                \addplot[blue]{x};
        \nextgroupplot
                \addplot[blue]{x};
        \nextgroupplot[ylabel={Range3 }]
                \addplot[blue]{x};
        \nextgroupplot
                \addplot[blue]{x};
        \nextgroupplot[xlabel={Number of Threads},ylabel={Range4 }]
                \addplot[blue]{x};
        \nextgroupplot[xlabel={Number of Threads}]
                \addplot[blue]{x};
                \coordinate (bot) at (rel axis cs:0,0);% coordinate at bottom of the last plot
    \end{groupplot}
    \path (top-|current bounding box.west)-- 
          node[anchor=south,rotate=90] {throughput} 
          (bot-|current bounding box.west);
\end{tikzpicture}

\end{document}

enter image description here

esdd
  • 85,675