I am trying to draw a rotated ellipse on a TH2. I would expect this to be straight forward, but I guess I do not understand something very basic. Here is a minimal example showing my problem. Using the attached ROOT file and this script:
void minimal() {
TFile* fIn = new TFile("minimal.root","READ");
TH2F* hist = (TH2F*) fIn->Get("zBands");
TCanvas* canvas = new TCanvas("c1","c1");
gPad->SetLogz();
hist->Draw("colz");
TEllipse* ellipse = new TEllipse(232, 7036, 10, 50, 0, 360);
//TEllipse* ellipse = new TEllipse(232, 7036, 10, 50, 0, 360, -45);
ellipse->SetLineColor(1);
ellipse->SetLineWidth(3);
ellipse->SetFillColor(0);
ellipse->SetFillStyle(4000);
ellipse->Draw("same");
}
But I want the ellipse to be rotated by -45 degrees (the “-” sign means clockwise) in order to outline the distribution on the plot. So I added a rotate argument (the line that is commented out in the above script). This produces:
Which is absolutely not what I expected based on the example from https://root.cern.ch/doc/v606/classTEllipse.html. I’ve tried a lot of other things since then and have had no luck. All I want is to rotate the ellipse in the first plot by -45 degrees. I must be missing something something very basic. Any help is appreciated.
The ROOT file that contains the TH2 is here: minimal.root (186.3 KB)
Thanks for the reply. Unfortunately, this example does not solve the problem in my original post. I am also confused since your response does not address my minimal example. To repeat the main points:
I have a TH2, and want to draw a rotated ellipse on it.
I can draw an ellipse (not rotated), which produces the first plot in my original post
I add the rotate argument, which produces a nonsense result in the second plot
Again, all I want to do is draw a rotated ellipse on my TH2. It can’t be this hard, right? Any help is appreciated. Thanks.