Problem in Canvas

Dear Experts,

I’m trying to draw some histograms from root file and I noticed a strange thing. Firstly I’m using following lines to draw a histogram,

TCanvas *ratio4allpt1 = new TCanvas("ratio4allpt1","AntiLambda/Lambda, Eta, all, pt>1.0,27");
MCEtaAntiLambdatoLambdapt1eta051->SetStats(kFALSE);
MCEtaAntiLambdatoLambdapt1eta051->SetBit(TH1::kNoTitle);
MCEtaAntiLambdatoLambdapt1eta051->GetYaxis()->SetRangeUser(0,1.3);
MCEtaAntiLambdatoLambdapt1eta051->Draw("e1p");
MCEtaAntiLambdatoLambdapt1eta091->SetStats(kFALSE);
MCEtaAntiLambdatoLambdapt1eta091->SetBit(TH1::kNoTitle);
MCEtaAntiLambdatoLambdapt1eta091->GetYaxis()->SetRangeUser(0,1.3);
MCEtaAntiLambdatoLambdapt1eta091->Draw("e1psame");
MCEtaAntiLambdatoLambdapt1eta251->SetStats(kFALSE);
MCEtaAntiLambdatoLambdapt1eta251->SetBit(TH1::kNoTitle);
MCEtaAntiLambdatoLambdapt1eta251->GetYaxis()->SetRangeUser(0,1.3);
MCEtaAntiLambdatoLambdapt1eta251->Draw("e1psame");
ratio4allpt1->BuildLegend(0.44,0.36,0.97,0.56);
ratio4allpt1->Update(); 

Result histogram could be seen as attached 6.gif file. When I moved the legend position, histogram shape completely changed as 5.gif file. Could you please help me to understand where am I doing a mistake?

Thank you,

Kind regards,

Ayben




swap the call to Update, ie, do:

ratio4allpt1->Update(); ratio4allpt1->BuildLegend(0.44,0.36,0.97,0.56);
Rene

Hello Rene,

I tried to use forceupdate() instead of update() and it worked.

Thank you,

Ayben