graph - gnuplot to plot muliple data set from a file and group all this bars -
i want plot column 3 , 4 bars each data set in file, data set identified multiple newline , referred using index show in script below. can draw data "linespoint". graph looks my graph. want plot data "boxes" i want graph this.
x-axis have column 3 (1,2,3) , y-axis have column 4, each value of x (1,2,3) there should 2 bars, 1 index 0 , second index 1.
data file looks like:
2-100
2 100 1 3.10 249
2 100 2 3.41 250
2 100 4 3.70 249
3-100
3 100 1 3.10 252
3 100 2 3.48 252
3 100 4 3.72 254
2-100 3-100 used title "first row of block , first column", first 4 lines read "index o" in script , second 4 lines "index 1"
script used:
plot \ "$1" index 0 using 3:4 boxes fs solid title columnhead(1),\ "$1" index 1 using 3:4 boxes fs solid title columnhead(1)
i've reformatted datafile little bit (at least, if understood original question correctly) -- looks like:
2-100 2 100 1 3.10 249 2 100 2 3.41 250 2 100 4 3.70 249 3-100 3 100 1 3.10 252 3 100 2 3.48 252 3 100 4 3.72 254
you should able format datafile using sed
:
sed -e '/^$/ d' -e '/[0-9]-100/{x;p;p;x}' datafile.dat # #remove newlines #reinsert newlines appropriate
(this assumes column heads start number (0-9) , "-100". you're re might need little more interesting if datafile little more complicated.
this can plotted using:
set yrange [0:*] set style fill solid plot [i=0:1] 'test2.dat' index u ($3+i*0.25):4:(0.25) w boxes title columnhead(1)
of course, can break loop assign special properties each plot or whatever...
if want special labels, can this
set xtics scale 0,0 format "" set xtics ("this @ 1" 1, "this @ 2" 2, "this @ 3" 3)
before plot command.
here's using above png (libgd) terminal:
Comments
Post a Comment