It works in the batch mode. Thanks for this idea, I didn’t know about this option but still this is just a partial solution. Do you have idea why it falls without the batch mode? Because I have encountered a new problem with the batch mode and that is drawing of THstack. In the batch mode, I can not set properties of a THstack (name of axis etc.) because it always crashes and I assume that this has a connection with the batch mode and the fact that a THstack is needed to be drawn before any change is made… Should I make a new topic from this?
For example this code always crashes in the batch mode for me:
void candleplotstack()
{
gStyle->SetTimeOffset(0);
TRandom *rng = new TRandom();
TDatime *dateBegin = new TDatime(2010,1,1,0,0,0);
TDatime *dateEnd = new TDatime(2011,1,1,0,0,0);
int bins = 1000;
TH2I *h1 = new TH2I("h1","Machine A",6,dateBegin->Convert(),dateEnd->Convert(),bins,0,1000);
TH2I *h2 = new TH2I("h2","Machine B",6,dateBegin->Convert(),dateEnd->Convert(),bins,0,1000);
TH2I *hsum = new TH2I("h4","Sum",6,dateBegin->Convert(),dateEnd->Convert(),bins,0,1000);
float Rand;
for (int i = dateBegin->Convert(); i < dateEnd->Convert(); i+=86400*30) {
for (int j = 0; j < 1000; j++) {
Rand = rng->Gaus(500+sin(i/10000000.)*100,50); h1->Fill(i,Rand); hsum->Fill(i,Rand);
Rand = rng->Gaus(500+sin(i/12000000.)*100,50); h2->Fill(i,Rand); hsum->Fill(i,Rand);
}
}
h2->SetLineColor(kRed);
hsum->SetFillColor(kGreen);
TCanvas *c1 = new TCanvas();
THStack *hs = new THStack("hs","Machine A+B");
hs->Add(h1);
hs->Add(h2,"candle2");
hs->Add(hsum, "violin1");
hs->Draw("candle3");
hs->GetXaxis()->SetNdivisions(410);
gPad->SetGrid(1,0);
hs->GetXaxis()->SetTimeDisplay(1);
hs->GetXaxis()->SetTimeFormat("%m/%y");
hs->GetXaxis()->SetTitle("Date [month/year]");
c1->Modified();
gPad->BuildLegend(0.75,0.75,0.95,0.95,"");
}
with this error/warning:
warning: invalid memory pointer passed to a callee:
hs->GetXaxis()->SetNdivisions(410);