source: branches/stable/GDE/PROBCONS/probcons/MakeGnuPlot.cc

Last change on this file was 10405, checked in by aboeckma, 11 years ago

added probcons

File size: 1.5 KB
Line 
1/////////////////////////////////////////////////////////////////
2// MakeGnuPlot.cc
3/////////////////////////////////////////////////////////////////
4
5#include <cstdlib>
6#include <iostream>
7#include <fstream>
8
9using namespace std;
10
11int main (int argc, char **argv){
12 
13  if (argc == 1 || argc > 3){
14    cerr << "Usage: makegnuplot annotscores [refscores]" << endl;
15    exit (1);
16  }
17
18  ifstream data (argv[1]);
19
20  if (data.fail()){
21    cerr << "ERROR: Could not open file " << argv[1] << endl;
22    exit (1);
23  }
24 
25  int x, ct = 0;
26  while (data >> x) ct++;
27  data.close();
28 
29  ofstream out ("temporary_gnuplot_script");
30 
31  if (out.fail()){
32    cerr << "ERROR: Could not create temporary file." << endl;
33    exit (1);
34  }
35
36  out << "set title \"Column Reliability Scores\"" << endl
37      << "set xlabel \"Alignment Position\"" << endl
38      << "set ylabel \"Column Reliability\"" << endl
39      << "set xr [1:" << ct << "]" << endl
40      << "set term postscript enhanced color" << endl
41      << "set output \"reliability.ps\"" << endl;
42 
43  if (argc == 3){
44    out << "set style fill solid 0.5 noborder" << endl
45        << "plot \"" << argv[2] << "\" title \"actual\" with boxes lt 2, \\" << endl
46        << "     \"" << argv[1] << "\" title \"predicted\" with histeps lt 1 lw 3" << endl;
47  }
48  else 
49    out << "plot \"" << argv[1] << "\" title \"predicted\" with histeps lt 1 lw 3" << endl;
50
51  out.close();
52
53  if (system ("gnuplot temporary_gnuplot_script") == -1){
54    cerr << "ERROR: Could not run Gnuplot correctly." << endl;
55    exit (1);
56  }
57 
58  //system ("rm temporary_gnuplot_script");
59}
Note: See TracBrowser for help on using the repository browser.