How do I create a graph multiple Y axes(more than 2) stacked one over the other with a common X axis?

Graph with multiple y axis

See attached figure. Each zero in y direction represents the beginning of new y axis.

  • 1
    Welcome to TeX.SX! Take a look at the groupplots library for pgfplots, that is useful for such things. – Torbjørn T. May 11 '16 at 9:32

A quick example with groupplots.

 group style={
  group size=1 by 4,  % sets number of columns and rows in groupplot array
  vertical sep=0pt,   % vertical distance between axes
 axis y line=left, % y axis line on left side only
 xmin=0,xmax=10,   % set axis
 ymin=0,           % limits
 domain=1:9,       % domain, just for example
 width=10cm,       % width
 height=3cm,       % and height for each axis
 scale only axis,  % disregard labels and ticks for scaling
 no markers, 
 enlarge y limits=upper,

    ylabel style={at={(rel axis cs:0,1)},above,rotate=-90}, %move ylabel a bit
    axis x line=none] % remove x-axis lines

\nextgroupplot[axis x line=none]
 \addplot{-x + 10}; 

\nextgroupplot[axis x line=none]

    axis x line=bottom, % only x axis line at bottom
    xlabel style={at={(rel axis cs:1,0)},right}]
 \addplot+[samples=200] {abs(sin(x*180/pi))}; 


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.