Hi all,
I have a custom TGAxis which shows up at the right position if the 2D histogram is drawn with “colz” but disappears if it is drawn with “cont4z”. Any ideas to solve that issue?
void Axis() {
TH2D* H = new TH2D("H", "H", 24, -3, 3, 24, -3, 3);
for (unsigned int i = 0; i < 100000; ++i) {
H->Fill(-2 + 4*gRandom->Rndm(), -2 + 4*gRandom->Rndm());
}
TCanvas* C = new TCanvas();
C->cd();
C->Range(-3, -3, 3, 3);
//H->Draw("colz"); // works
H->Draw("cont4z"); // does not work
TGaxis* YAxis = new TGaxis(gPad->GetUxmin(),
gPad->GetUymax(),
0.9999*gPad->GetUxmin(),
gPad->GetUymin(),
H->GetYaxis()->GetXmin(),
H->GetYaxis()->GetXmax(), 510, "-S");
YAxis->ImportAxisAttributes(H->GetYaxis());
YAxis->CenterTitle(true);
YAxis->SetTitle("New");
YAxis->SetLabelOffset(-0.03f);
YAxis->SetTickLength(0.015f);
YAxis->SetTitleOffset(-1.5f);
// Remove the current axis
H->GetYaxis()->SetLabelOffset(999);
H->GetYaxis()->SetTickLength(0);
// Draw the new axis
YAxis->Draw();
C->Update();
C->SaveAs("Axis.pdf");
}
Thanks,
Andreas
ROOT Version: 6.24.06
Platform: Mac OS 12.6
Compiler: Xcode default