Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

This can be considered a combination of the following questions

How can a title be placed for a group of pgfplots?

Align ylabels of grouped plots at a common line

The following piece of code renders two plots, one above the other, and attaches a common ylabel to both.

\documentclass[tikz]{standalone}
\usepackage[T1]{fontenc}
\usepackage{cmbright}
%% Just some font that has serifs for maths                                          
%% Yes; this particular combination is horrible                                      
\usepackage{euler}
\usepackage{pgfplots}
\usepgfplotslibrary{units}
\pgfplotsset{compat=newest}
\usepgfplotslibrary{groupplots}
\begin{document}
\begin{tikzpicture}
  \begin{groupplot}[group style={group size=1 by 2}]
    \nextgroupplot[ylabel = ylabel, y unit = m/s]
    \addplot coordinates {(0,0) (1,1) (2,2)};
    \nextgroupplot
    \addplot coordinates {(0,2) (1,1000) (2,0)};
  \end{groupplot}

  \node at ($(group c1r1.west)!0.5!(group c1r2.west)$)
  [xshift=-1.5cm] % Problem #1: estimated distance                                   
  {\rotatebox{90}{ylabel [$\mathrm{m/s}$]}};
  % Problem #2: Copying pgfplots internals,                                          
  % i.e. /pgfplots/unit code/.code 2 args={\mathrm{#1#2}}                            
\end{tikzpicture}
\end{document}

Rendering

There are two problems: It would be nice if the near ticks mechanics worked for this case, too, i.e. the optimal distance from both plots were determined automatically; on top of that, if units are used, the ylabel isn't just a bit of text anymore, but something more complicated; and I'd rather not reinvent that machinery.

Is there a better way to handle this?

share|improve this question
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.