Hello,
I am attempting to plot an ellipse overlaid on a TH2F. The ellipse spills over the axes of the TH2F. I would like to make it so that the histogram axes cut off the ellipse in a nice looking way. The following two plots are generated by the attached code.
If anyone knows of a nice way to accomplish this, or can help fix my code for the second plot to make it look nice, I would appreciate it greatly.
Joe
void EllipseClip()
{
TCanvas* c1 = new TCanvas("c1","c1",50,50,400,800);
TH2F* h2 = new TH2F("h2","h2",10,0,10,10,0,10);
c1->Range(0,0,10,10);
c1->Divide(1,2);
c1->cd(1);
h2->Draw();
TEllipse* AnOffensiveEllipse = new TEllipse(2.5,2.5,8,1,0,360,135);
AnOffensiveEllipse->SetFillColor(kBlue);
AnOffensiveEllipse->Draw("same");
c1->cd(2);
h2->Draw();
printf("\n User coords: (%f,%f,%f,%f)",c1_2->GetX1(),c1_2->GetY1(),c1_2->GetX2(),c1_2->GetY2());
double ndcx0 = (0-c1_2->GetX1())/(c1_2->GetX2()-c1->GetX1());
double ndcy0 = (0-c1_2->GetY1())/(c1_2->GetY2()-c1->GetY1());
double ndcx10 = (10-c1_2->GetX1())/(c1_2->GetX2()-c1->GetX1());
double ndcy10= (10-c1_2->GetY1())/(c1_2->GetY2()-c1->GetY1());
printf("\n NDC coords: (%f,%f,%f,%f)",ndcx0,ndcy0,ndcx10,ndcy10);
//TPad* sp = new TPad("sp","sp",ndcx0,ndcy0,ndcx10,ndcy10);
TPad* sp = new TPad("sp","sp",0.15,0.15,1-0.15,1-0.15);
sp->SetFillStyle(4000);
sp->Draw("same");
sp->Range(0,0,10,10);
sp->cd();
TEllipse* ASlightlyLessOffensiveEllipse = new TEllipse(2.5,2.5,8,1,0,360,135);
ASlightlyLessOffensiveEllipse->SetFillStyle(4000);
ASlightlyLessOffensiveEllipse->SetLineColor(kBlue);
ASlightlyLessOffensiveEllipse->Draw();
}