Suppose I have two root files, both containing a histogram hist
. If I wanted to plot both of them into a single figure, I would use something like this:
{
canvas = new TCanvas("canvas", "My Canvas");
canvas->SetFillColor(10);
gStyle->SetOptStat(0);
f = new TFile("file1.root", "READONLY");
hist->SetNormFactor(1.0);
hist->SetLineColor(4);
hist->Draw();
f = new TFile("file2.root", "READONLY");
hist->SetNormFactor(1.0);
hist->SetLineColor(2);
hist->Draw("same");
}
If I run the above code in a fresh root
session with .x plot.c
(where plot.c
is the name of the program above), I get the expected result. However, if I repeat the command .x plot.c
, I only get a figure displaying one of the two histograms.
What am I missing?
Thank you very much in advance.