Open kratsg opened 7 years ago
void DrawTextWithAngle()
{
auto *C = gPad->GetCanvas();
Double_t RM = C->GetRightMargin();
Double_t LM = C->GetLeftMargin();
Double_t TM = C->GetTopMargin();
Double_t BM = C->GetBottomMargin();
Double_t W = Double_t(C->GetWw()*(1.-LM-RM));
Double_t H = Double_t(C->GetWh()*(1.-TM-BM));
Double_t A = (180.*TMath::ATan(H/W))/(TMath::Pi());
auto *t = new TText(0.3,0.3,Form("This text is parallel to the line the angle is %f degrees",A));
t->SetTextAngle(A);
t->Paint();
}
void textangle()
{
auto *C = new TCanvas("C","C", 1600, 1200);
C->SetRightMargin(0.16);
auto *h = new TH2F("h","h",20,0.,2500.,20,0.,2500);
h->Fill(1000.,1000.,123.);
h->Fill(1500.,1000.,1230.);
h->Draw("col");
h->Draw("text45 same");
auto *l = new TLine(0.,0.,2300.,2300.);
l->Draw();
gPad->Update();
auto *ex = new TExec("ex","DrawTextWithAngle();");
ex->Draw();
}
macro should allow us to fix up the angle.
See: