title: How can I create a barseries plot using both grouped and stacked styles in MATLAB?
body: <p>The MATLAB <a href="http://www.mathworks.com/help/techdoc/ref/bar.html" rel="nofollow noreferrer">bar documentation</a> states the following:</p>
  
  <blockquote>
    <p>bar(...,'style') specifies the style of the bars. 'style' is 'grouped' <strong>or</strong> 'stacked'. Default mode of display is 'grouped'.</p>
  </blockquote>
  
  <p>However, I would like to achieve <strong>both</strong> at the same time. Let me elaborate by giving an example:</p>
  
  <pre><code>Y = [1.0 0.5 0.7
       2.0 1.5 2.0
       5.0 4.0 5.0
       4.0 4.0 4.5
       3.0 2.0 2.0];
  
  bar(Y,'group');
  </code></pre>
  
  <p>This code produces the following <em>grouped</em> barseries plot, with 5 different sets of 3 bars grouped together:</p>
  
  <p><img src="https://i.stack.imgur.com/CIpNU.jpg" alt="enter image description here"></p>
  
  <pre><code>bar([repmat(0.5,5,1) Y(:,1)-0.5],'stack');
  </code></pre>
  
  <p>And this code produces the following <em>stacked</em> barseries plot, using just the first column of the above defined matrix <code>Y</code>:</p>
  
  <p><img src="https://i.stack.imgur.com/BIkc8.jpg" alt="enter image description here"></p>
  
  <p>I would like to merge these two, to get a barseries plot which is grouped and stacked at the same time. So the desired result would be like the first picture and each of the three bars in a set would be stacked like the second picture. </p>