Changeset 36 for trunk/lib/Stats.cc


Ignore:
Timestamp:
Jan 13, 2006, 2:05:53 AM (16 years ago)
Author:
Jari Häkkinen
Message:

Changed Gnuplot interface. Fixed sever bug in Stats::accumulated(void).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Stats.cc

    r35 r36  
    22
    33#include "Stats.h"
     4#include "Gnuplot.h"
    45#include "utility.h"
    56
     
    2223  std::vector<double> Stats::accumulated(void) const
    2324  {
    24     std::vector<u_int> sum;
    2525    if (map_.empty())
    2626      return std::vector<double>();
    2727
    28     // sum of all users
    29     std::accumulate(map_.begin(), map_.end(), sum,
    30         PairValuePlus<std::string,u_int>());
     28    // sum of all users
     29    std::vector<u_int> sum;
     30    sum=std::accumulate(map_.begin(), map_.end(), sum,
     31                        PairValuePlus<std::string,u_int>());
    3132
    3233    // calculate accumulated sum
     
    6061      vec[rev]++;
    6162    map_[user]=vec;
    62 
    6363  }
    6464
     
    7070      exit(-1);
    7171    }
    72     // Jari, temporary empty files are created that needs to be removed.
    7372    std::string cmd=std::string("set term png; set output '")+name+".png'";
    7473    gnuplot_pipe_.command(cmd);
    75     std::vector<double> x=accumulated();
    76     gnuplot_pipe_.plot_y(x);
    77     for (MapConstIter_ i= map_.begin(); i != map_.end(); i++) {
    78       x=accumulated(i->first);
    79       gnuplot_pipe_.plot_y(x);
    80     }
     74    gnuplot_pipe_.plot(accumulated());
     75    for (MapConstIter_ i= map_.begin(); i != map_.end(); i++)
     76      gnuplot_pipe_.replot(accumulated(i->first));
     77
     78    // Jari, must rewrite output once since the replots above are not
     79    // added to the plot. Rather, the plot only contains the result
     80    // from the first 'plot' call.
     81    gnuplot_pipe_.command(cmd);
     82    gnuplot_pipe_.command("replot");
    8183    return std::string(name)+".png";
    8284  }
Note: See TracChangeset for help on using the changeset viewer.