Creating histogram point groups with gnuplot

I want to create such a graph using gnuplot:

enter image description here

I have different data points for a fixed point in time. I want to group these data points around representing the value of x. These data points come from different data files, which look like this:

9 0.333 9 0.308 9 0.289 15 0.356 15 0.836 15 0.364 15 0.347 0 0.386 0 0.318 0 0.347 0 0.322 12 0.351 12 0.314 12 0.314 

I am currently building data using a loop like this:

 set xtics (0, 3, 6, 9, 12, 15, 18, 21) plot for [i=1:15] sprintf('file_%i.dat', i) using 1:2 with points 

but they overlap. How to do it with gnuplot?

+4
source share
1 answer

You may have to manually set the offset for each set of points, for example:

 #!/usr/bin/env gnuplot o1 = 0.1 # x-offset for each set of points on plot n = 15 # number of files, integer # x-offset for leftmost set of points. # this will center all sets of points around the central x value, # whether there are an even or odd number of sets o2 = (n/2.0 - 0.5) * o1 set xtics (0, 3, 6, 9, 12, 15, 18, 21) plot for [i=1:n] sprintf('file_%i.dat', i) using ($1-o2+i*o1):2 with points 

(I think this should work, but I can't check it right now.)

+2
source

All Articles