title: Gnuplot Histogram Cluster (Bar Chart) with One Line per Category
body: <h2>Histogram Cluster / Bar Chart</h2>
  
  <p>I'm trying to generate the following <strong>histogram cluster</strong> out of this data file with <strong>gnuplot</strong>, where each <strong>category</strong> is represented <strong>in a separate line</strong> per year in the data file:</p>
  
  <pre><code># datafile
  year   category        num_of_events
  2011   "Category 1"    213
  2011   "Category 2"    240
  2011   "Category 3"    220
  2012   "Category 1"    222
  2012   "Category 2"    238
  ...
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/Odlfn.png" alt="desired histogram cluster"></p>
  
  <p>But I don't know how to do it with one line per category. I would be glad if anybody has got an idea how to do this with gnuplot.</p>
  
  <h2>Stacked Histogram Cluster / Stacked Bar Chart</h2>
  
  <p>Even better would be a <strong>stacked</strong> histogram cluster like the following, where the <strong>stacked sub categories</strong> are represented by <strong>separate columns</strong> in the datafile:</p>
  
  <pre><code># datafile
  year   category        num_of_events_for_A    num_of_events_for_B
  2011   "Category 1"    213                    30
  2011   "Category 2"    240                    28
  2011   "Category 3"    220                    25
  2012   "Category 1"    222                    13
  2012   "Category 2"    238                    42
  ...
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/yhbPC.png" alt="desired stacked histogram cluster"></p>
  
  <p>Thanks a lot in advance!</p>