I am having trouble plotting a datafile like this as a grouped histogram.
x-axis group y-axis
1 11 0.1123
1 22 0.1687
1 33 0.1312
2 11 0.4567
2 22 0.4578
2 33 0.7465
3 11 0.7532
3 22 0.7742
3 33 0.7123
So I would like the histogram to be x-axis against y-axis, but within each x-axis "bin" there are 3 different bars, one for each group, like this image:

I can get a histogram of x against y using plot 'file.dat' using 1:3 but can't get it to group by the second column. How do I do this?
The way I'd do this is to reformat the data in columns like this:
x-axis group11 group22 group33
1 0.1123 0.1687 0.1312
2 0.4567 0.4578 0.7465
3 0.7532 0.7742 0.7123
Then it's the usual gnuplot histogram.
set style fill solid 1.00 border -1
set style data histogram
set style histogram cluster gap 2
plot 'data2.dat' using 2 t "11", '' using 3 t "22", '' using 4:xtic(1) t "33"
Result looks like this:

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With