This shows you the differences between two versions of the page.
— | root:two_stats_boxes [2009/03/27 14:56] (current) – created viktorh | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== How to overlay tow histograms and draw both stats boxes ====== | ||
+ | |||
+ | void myfunction() | ||
+ | { | ||
+ | ... | ||
+ | TCanvas *c = new TCanvas(...) | ||
+ | TH1D *h1 = new TH1D(...) ; // histo 1 | ||
+ | TH1D *h2 = new TH1D(...) ; // histo 2 | ||
+ | |||
+ | // set stats options (show histo title, nEntries, mean, rms) | ||
+ | gStyle-> | ||
+ | |||
+ | // draw histo 1 | ||
+ | h1-> | ||
+ | |||
+ | // get stats box | ||
+ | gPad-> | ||
+ | TPaveStats *statsbox = (TPaveStats*)gPad-> | ||
+ | |||
+ | // get (default) y position of stats box (histo h1) | ||
+ | double y1 = statsbox-> | ||
+ | double y2 = statsbox-> | ||
+ | |||
+ | // set new position of stats box (histo h1) | ||
+ | double newy1 = 2 * y1 - y2; // new (lower) y start position of stats box | ||
+ | double newy2 = y1; // new (upper) y start position of stats box | ||
+ | statsbox-> | ||
+ | statsbox-> | ||
+ | |||
+ | // draw histo 2 | ||
+ | h2-> | ||
+ | |||
+ | // Draw options: | ||
+ | // " | ||
+ | // " | ||
+ | |||
+ | ... | ||
+ | } | ||
+ | |||