#set terminal postscript eps enhanced "Courier" color 18
set term png truecolor enhanced font "Courier,18"

set style fill transparent solid 0.2 noborder

set logscale x

set xlabel "t"
set ylabel "perr"

fname = "qsar"
set yrange [0.15:0.35] 

mychar(a) = (a == 1) ? 'S' : 'Q'

ratboostQFile(n,v) = sprintf("%s_test_ratboostQ_%d_%s.txt",fname,n,v)
ratboostQTitle(b,v) = sprintf("RatBoost%s_{%d}",mychar(v),b)
ratboostAFile(n,v) = sprintf("%s_test_ratboostA_%d_%s.txt",fname,n,v)
ratboostATitle(b) = sprintf("RatBoostA_{%d}",b)

ratboostEFile(n,v) = sprintf("%s_test_ratboostE_%d_%s.txt",fname,n,v)

adaboostRFile = sprintf("%s_test_adaboostR.txt",fname)
adaboostSSFile = sprintf("%s_test_adaboostSS.txt",fname)
concatAdaboostFile = sprintf("< paste %s_test_adaboostR.txt %s_test_adaboostSS.txt",fname,fname)
ratboostFile = sprintf("%s_test_ratboost.txt",fname)

saveFile24 = sprintf("test_err_%s_2_4_bits_min_logscale.png",fname)
saveFile68 = sprintf("test_err_%s_6_8_bits_min_logscale.png",fname)

saveFileA2 = sprintf("test_err_A_%s_2_bits_min_logscale.png",fname)
saveFileA3 = sprintf("test_err_A_%s_3_bits_min_logscale.png",fname)
saveFileA4 = sprintf("test_err_A_%s_4_bits_min_logscale.png",fname)
saveFileA5 = sprintf("test_err_A_%s_5_bits_min_logscale.png",fname)
saveFileA6 = sprintf("test_err_A_%s_6_bits_min_logscale.png",fname)
#saveFileA7 = sprintf("test_err_A_%s_7_bits_min_logscale.png",fname)
#saveFileA8 = sprintf("test_err_A_%s_8_bits_min_logscale.png",fname)

saveFileQ2 = sprintf("test_err_Q_%s_2_bits_min_logscale.png",fname)
saveFileQ3 = sprintf("test_err_Q_%s_3_bits_min_logscale.png",fname)
saveFileQ4 = sprintf("test_err_Q_%s_4_bits_min_logscale.png",fname)
saveFileQ5 = sprintf("test_err_Q_%s_5_bits_min_logscale.png",fname)
saveFileQ6 = sprintf("test_err_Q_%s_6_bits_min_logscale.png",fname)
#saveFileQ7 = sprintf("test_err_Q_%s_7_bits_min_logscale.png",fname)
#saveFileQ8 = sprintf("test_err_Q_%s_8_bits_min_logscale.png",fname)

saveFile2 = sprintf("test_err_%s_2_bits_min_logscale.png",fname)
saveFile3 = sprintf("test_err_%s_3_bits_min_logscale.png",fname)
saveFile4 = sprintf("test_err_%s_4_bits_min_logscale.png",fname)

saveFileE = sprintf("test_err_%s_AdaRatE_logscale.png",fname)


set style line 1 lc rgb "#000000" lt 1 lw 6
set style line 2 lc rgb "#000000" lt 1 lw 5
set style line 3 lc rgb "#000000" lt 18 lw 6
set style line 4 lc rgb "#000000" lt 18 lw 3
set style line 5 lc rgb "#AAAAAA" lt 1 lw 6
set style line 6 lc rgb "#FF0000" lt 1 lw 3
set style line 7 lc rgb "#AAAAAA" lt 18 lw 6
set style line 8 lc rgb "#FF0000" lt 18 lw 5

set style line 9 lc rgb "#0000FF" lt 10 lw 5
set style line 10 lc rgb "#FF0000" lt 10 lw 5
set style line 11 lc rgb "#00FF00" lt 10 lw 5

set style line 12 lc rgb "#FFA500" lt 18 lw 3

set style line 13 lc rgb "#800080" lt 10 lw 5


min(x, y) = (x < y ? x : y)

set xrange [1:20000]
set xtics add ("50000" 50000) 

set output saveFileA2 

plot 	adaboostSSFile using 1:($2-$3):($2+$3) with filledcurves ls 9 notitle, adaboostSSFile title 'AdaBoost' with lines ls 9,ratboostFile using 1:($2-$3):($2+$3) with filledcurves ls 11 notitle,ratboostFile title'RatBoost' with lines ls 11,ratboostAFile(3,"false") title	ratboostATitle(2) with lines ls 2, ratboostAFile(3,"false")  using 1:($2-$3):($2+$3) with filledcurves ls 2 notitle

set output saveFileA3

plot 	adaboostSSFile using 1:($2-$3):($2+$3) with filledcurves ls 9 notitle, adaboostSSFile title 'AdaBoost' with lines ls 9,ratboostFile using 1:($2-$3):($2+$3) with filledcurves ls 11 notitle,ratboostFile title'RatBoost' with lines ls 11,ratboostAFile(7,"false") title	ratboostATitle(3) with lines ls 2, ratboostAFile(7,"false")  using 1:($2-$3):($2+$3) with filledcurves ls 2 notitle

set output saveFileA4 

plot 	adaboostSSFile using 1:($2-$3):($2+$3) with filledcurves ls 9 notitle, adaboostSSFile title 'AdaBoost' with lines ls 9,ratboostFile using 1:($2-$3):($2+$3) with filledcurves ls 11 notitle,ratboostFile title'RatBoost' with lines ls 11,ratboostAFile(15,"false") title	ratboostATitle(4) with lines ls 2, ratboostAFile(15,"false")  using 1:($2-$3):($2+$3) with filledcurves ls 2 notitle

set output saveFileA5

plot 	adaboostSSFile using 1:($2-$3):($2+$3) with filledcurves ls 9 notitle, adaboostSSFile title 'AdaBoost' with lines ls 9,ratboostFile using 1:($2-$3):($2+$3) with filledcurves ls 11 notitle,ratboostFile title'RatBoost' with lines ls 11,ratboostAFile(31,"false") title	ratboostATitle(5) with lines ls 2, ratboostAFile(31,"false")  using 1:($2-$3):($2+$3) with filledcurves ls 2 notitle

set output saveFileA6

plot 	adaboostSSFile using 1:($2-$3):($2+$3) with filledcurves ls 9 notitle, adaboostSSFile title 'AdaBoost' with lines ls 9,ratboostFile using 1:($2-$3):($2+$3) with filledcurves ls 11 notitle,ratboostFile title'RatBoost' with lines ls 11,ratboostAFile(63,"false") title	ratboostATitle(6) with lines ls 2, ratboostAFile(63,"false")  using 1:($2-$3):($2+$3) with filledcurves ls 2 notitle

set output saveFileQ2 

plot 	adaboostSSFile using 1:($2-$3):($2+$3) with filledcurves ls 9 notitle, adaboostSSFile title 'AdaBoost' with lines ls 9,ratboostFile using 1:($2-$3):($2+$3) with filledcurves ls 11 notitle,ratboostFile title'RatBoost' with lines ls 11,ratboostQFile(3,"true") title	ratboostQTitle(2,1) with lines ls 8,ratboostQFile(3,"true")  using 1:($2-$3):($2+$3) with filledcurves ls 8 notitle,ratboostQFile(3,"false") title	ratboostQTitle(2,0) with lines ls 12,ratboostQFile(3,"false")  using 1:($2-$3):($2+$3) with filledcurves ls 12 notitle

set output saveFileQ3 

plot 	adaboostSSFile using 1:($2-$3):($2+$3) with filledcurves ls 9 notitle, adaboostSSFile title 'AdaBoost' with lines ls 9,ratboostFile using 1:($2-$3):($2+$3) with filledcurves ls 11 notitle,ratboostFile title'RatBoost' with lines ls 11,ratboostQFile(7,"true") title	ratboostQTitle(3,1) with lines ls 8,ratboostQFile(7,"true")  using 1:($2-$3):($2+$3) with filledcurves ls 8 notitle,ratboostQFile(7,"false") title	ratboostQTitle(3,0) with lines ls 12,ratboostQFile(7,"false")  using 1:($2-$3):($2+$3) with filledcurves ls 12 notitle

set output saveFileQ4 

plot 	adaboostSSFile using 1:($2-$3):($2+$3) with filledcurves ls 9 notitle, adaboostSSFile title 'AdaBoost' with lines ls 9,ratboostFile using 1:($2-$3):($2+$3) with filledcurves ls 11 notitle,ratboostFile title'RatBoost' with lines ls 11,ratboostQFile(15,"true") title	ratboostQTitle(4,1) with lines ls 8,ratboostQFile(15,"true")  using 1:($2-$3):($2+$3) with filledcurves ls 8 notitle,ratboostQFile(15,"false") title	ratboostQTitle(4,0) with lines ls 12,ratboostQFile(15,"false")  using 1:($2-$3):($2+$3) with filledcurves ls 12 notitle

set output saveFileQ5

plot 	adaboostSSFile using 1:($2-$3):($2+$3) with filledcurves ls 9 notitle, adaboostSSFile title 'AdaBoost' with lines ls 9,ratboostFile using 1:($2-$3):($2+$3) with filledcurves ls 11 notitle,ratboostFile title'RatBoost' with lines ls 11,ratboostQFile(31,"true") title	ratboostQTitle(5,1) with lines ls 8,ratboostQFile(31,"true")  using 1:($2-$3):($2+$3) with filledcurves ls 8 notitle,ratboostQFile(31,"false") title	ratboostQTitle(5,0) with lines ls 12,ratboostQFile(31,"false")  using 1:($2-$3):($2+$3) with filledcurves ls 12 notitle

set output saveFileQ6 

plot 	adaboostSSFile using 1:($2-$3):($2+$3) with filledcurves ls 9 notitle, adaboostSSFile title 'AdaBoost' with lines ls 9,ratboostFile using 1:($2-$3):($2+$3) with filledcurves ls 11 notitle,ratboostFile title'RatBoost' with lines ls 11,ratboostQFile(63,"true") title	ratboostQTitle(6,1) with lines ls 8,ratboostQFile(63,"true")  using 1:($2-$3):($2+$3) with filledcurves ls 8 notitle,ratboostQFile(63,"false") title	ratboostQTitle(6,0) with lines ls 12,ratboostQFile(63,"false")  using 1:($2-$3):($2+$3) with filledcurves ls 12 notitle

set output saveFileE 

plot 	adaboostSSFile using 1:($2-$3):($2+$3) with filledcurves ls 9 notitle, adaboostSSFile title 'AdaBoost' with lines ls 9,ratboostFile using 1:($2-$3):($2+$3) with filledcurves ls 11 notitle,ratboostFile title'RatBoost' with lines ls 11, ratboostEFile(2047,"false") using 1:($2-$3):($2+$3) with filledcurves ls 13 notitle, ratboostEFile(2047,"false") title'RatBoostE' with lines ls 13






set output saveFile2 

plot 	adaboostSSFile using 1:($2-$3):($2+$3) with filledcurves ls 9 notitle, adaboostSSFile title 'AdaBoost' with lines ls 9,ratboostFile using 1:($2-$3):($2+$3) with filledcurves ls 11 notitle,ratboostFile title'RatBoost' with lines ls 11,ratboostQFile(3,"true") title	ratboostQTitle(2,1) with lines ls 8,ratboostQFile(3,"true")  using 1:($2-$3):($2+$3) with filledcurves ls 8 notitle,ratboostAFile(3,"false") title	ratboostATitle(2) with lines ls 2, ratboostAFile(3,"false")  using 1:($2-$3):($2+$3) with filledcurves ls 2 notitle


set output saveFile3

plot 	adaboostSSFile using 1:($2-$3):($2+$3) with filledcurves ls 9 notitle, adaboostSSFile title 'AdaBoost' with lines ls 9,ratboostFile using 1:($2-$3):($2+$3) with filledcurves ls 11 notitle,ratboostFile title'RatBoost' with lines ls 11,ratboostQFile(7,"true") title	ratboostQTitle(3,1) with lines ls 8,ratboostQFile(7,"true")  using 1:($2-$3):($2+$3) with filledcurves ls 8 notitle,ratboostAFile(7,"false") title	ratboostATitle(3) with lines ls 2, ratboostAFile(7,"false")  using 1:($2-$3):($2+$3) with filledcurves ls 2 notitle


set output saveFile4 

plot 	adaboostSSFile using 1:($2-$3):($2+$3) with filledcurves ls 9 notitle, adaboostSSFile title 'AdaBoost' with lines ls 9,ratboostFile using 1:($2-$3):($2+$3) with filledcurves ls 11 notitle,ratboostFile title'RatBoost' with lines ls 11,ratboostQFile(15,"true") title	ratboostQTitle(4,1) with lines ls 8,ratboostQFile(15,"true")  using 1:($2-$3):($2+$3) with filledcurves ls 8 notitle,ratboostAFile(15,"false") title	ratboostATitle(4) with lines ls 2, ratboostAFile(15,"false")  using 1:($2-$3):($2+$3) with filledcurves ls 2 notitle

