1

i have two data file listed below file1.dat

a        b               c       d(There is no colum name in my file)
70.9    70.4        71.3    65.6
70.8    70.9        72.8    68.1
72.00   72.4        70.6    67.9
70.2    71.5        71.7    70.9
71.00   71.2        71.1    71.7
71.5    71.3        71.1    71.4

file2.dat

 a           b       c      d(There is no colum name in my file)
70.9    67.5    71.3    64.67
72.2    71.2    72.8    65.5
72.4    70.2    70.6    68.6
71.6    72.1    71.3    67.9
70.2    72.2    71.1    70.8
71.2    71.7    71.9    71.7
72.00   71.4    71.7    71.3
70.8    71.7    71.4    71.3

i want to create a graph a1,a2 b1,b2 c1,c2 d1,d2 how it will possible?

the code:

set title "Unigram features ranked using MI of POSITIVE class" 
set title font ", 20" 
set xlabel "Feature Length"
set xlabel font ",20"
set ylabel "Accuracy(%)"
set yrange [65:75]
set ylabel font ",20"
set ytics font ", 20" 
set boxwidth 0.98

set key font ",18"
set style fill pattern #solid


set style histogram clustered #gap 5 title  offset character 0, 0, 0
set xtics font ", 20" 
set xtics ("100" 0, "300" 1, "500" 2, "1300" 3, "1500" 4, "1800" 5, "1900" 6, "2000" 7)
set style data histograms

plot "< paste without_threshold_POSITIVE.dat with_threshold_POSITIVE.dat" using 1:5 every ::1, \
"" using 2:6 every ::1, \
"" using 3:7 every ::1, \
"" using 4:8 every ::1

set output 'POSITIVE_test.eps'

set terminal postscript eps enhanced black
replot

please find the code..and try point out my mistake

user3512562
  • 233
  • 2
  • 3
  • 7

2 Answers2

1

As mentioned by Christoph in the comments, you need to preprocess your data, for which paste is a good tool:

paste file1.dat file2.dat > file3.dat

will paste your columns. Since you have 4 columns per file, in the new file3.dat columns 1 to 4 come from file1.dat and columns 5 to 8 come from file2.dat. Therefore you would need to plot using 1:5, using 2:6, using 3:7 and using 4:8:

plot "file3.dat" using 1:5 every ::1, \
"" using 2:6 every ::1, \
"" using 3:7 every ::1, \
"" using 4:8 every ::1

where with every ::1 I'm telling gnuplot to ignore the first line where you have non-plottable text (you could alternatively comment out this line using #). You can do the paste preprocessing inside gnuplot without the need to generate file3.dat:

plot "< paste file1.dat file2.dat" using 1:5 every ::1, \
"" using 2:6 every ::1, \
"" using 3:7 every ::1, \
"" using 4:8 every ::1
Miguel
  • 7,497
  • 2
  • 27
  • 46
  • error :plot "< paste without_threshold_POSITIVE.dat with_threshold_POSITIVE.dat" using 1:5 every ::1, "" using 2:6 every ::1, "" using 3:7 every ::1, "" using 4:8 every ::1 ^ "POSTIVE.plt", line 23: Too many columns in using specification – user3512562 Jun 06 '14 at 09:44
  • @user3512562 My answer works for the question you posted originally. You need to adapt it to your specific problem: if your data files don't have column headers then remove `every ::1` and if they have less than four columns each (which seems to be the origin of the error message you're getting) then you'll need to change the `using` options. – Miguel Jun 06 '14 at 09:58
  • yes i tried with deleting every ::1 so am getting an error like Too many columns in using specification – user3512562 Jun 06 '14 at 10:21
  • @user3512562 How many columns exactly are there in your files before processing them? – Miguel Jun 06 '14 at 10:28
  • The `histogram` plotting style requires only a single column, the x-value is choosen automatically. – Christoph Jun 06 '14 at 13:23
0

The histogram plotting style requires only a single column. I'm not completely sure, how you want your a1, a2, b1, b2 etc. columns to be arranged, and how your manual xtics come into play.

I assume, that the first x-value corresponds to the label for the first row, and so on.

Here is how you can set the a1 boxes beneath the a2 columns for comparison:

set title "Unigram features ranked using MI of POSITIVE class" 
set xlabel "Feature Length"
set ylabel "Accuracy(%)"
set yrange [65:75]
set boxwidth 0.98

set style fill solid

set style histogram clustered #gap 5 title  offset character 0, 0, 0
set xtics ("100" 0, "300" 1, "500" 2, "1300" 3, "1500" 4, "1800" 5, "1900" 6, "2000" 7)
set style data histograms

plot "file1.dat" using 1 every ::1 t 'a1', \
     "file2.dat" using 1 every ::1 t 'a2'

Should the b1, b2 columns be aligned between the a1,a2 column, i.e. grouped by row, or beneath each other in different histograms?

The result of the above script is (with 4.6.4):

enter image description here

Christoph
  • 47,569
  • 8
  • 87
  • 187