title: Gnuplot bar chart from this CSV input
body: <p>I have csv file data.dat for example with these values:</p>
  
  <pre><code>#W=1
  0;sqlite;11500
  1;hsql;14550
  2;h2;17550
  #W=2
  0;sqlite;11000
  1;hsql;13800
  2;h2;16500
  #W=3
  0;sqlite;11000
  1;hsql;13800
  2;h2;16500
  #W=4
  0;sqlite;11000
  1;hsql;13800
  2;h2;16500 
  </code></pre>
  
  <p>I need to plot bar charts into pdf. each data for each graph starts with title #W1,#W2....</p>
  
  <p>i have tried this script:</p>
  
  <pre><code> cat &lt;&lt; __EOF | gnuplot -persist
   set terminal pdf
   set output 'out.pdf'
   set datafile separator ";"
   set boxwidth 0.5
   set style fill solid
   plot "data2.dat" using 1:3:xtic(2) with boxes
  __EOF
  </code></pre>
  
  <p>giving this output:
  <img src="https://i.stack.imgur.com/X4EV5.png" alt="enter image description here"></p>
  
  <p>how can i make more graphs (4 in this example but there could more or less) from one datafile each graph separately under previous one? </p>
  
  <p><strong>Edit:</strong>
  each graph can have different number of bars not only three as in previous example. File data2.dat could also look like this: </p>
  
  <pre><code>#W=1
  0;sqlite;11500
  1;hsql;14550
  2;h2;17550
  3;derby;8500
  4;sqlite;13550
  5;h2;19250
  #W=2
  0;sqlite;11000
  1;hsql;13800
  </code></pre>
  
  <p>This script from Miguel answer works fine when there are 3 bars for each graph but i dont know how to change it to plot more or less bars.</p>
  
  <pre><code>cat &lt;&lt; __EOF | gnuplot -persist
  set terminal pdf
  set datafile separator ";"
  set boxwidth 0.5
  set style fill solid
  do for [i=0:3] {
  set output 'out'.i.'.pdf'
  plot "data2.dat" using 1:3:xtic(2) every ::(i*3)::(i*3+3) with boxes
  }
  __EOF
  </code></pre>
  
  <p>also if it would be possible i would like to have a graph tittle according to header value of each dataset (W=1, W=2....)</p>