Please read tips for efficient and successful posting and posting code
ROOT Version: 6.36.16
Platform: macosxarm64
Compiler: Apple clang version 21.0.0 (clang-2100.0.123.102)
There is probably an easy way to do this, but I haven’t found it. I would like to do something similar to hist->Draw(“surf3”) but with the histogram plotted as a lego(3) and associated function plotted as the contours on the upper plane. The closest that I can come is
int maxFill = 200000;
TH2D *myH = new TH2D("myH", "myH", 100, -3, 3, 100, -3, 3);
TF2 *myTF2 = new TF2("myTF2", "[0]*exp(-([2]*x*x + [3]*y*y)/[1])", -3, 3, -3, 3);
myTF2->SetParameters(10.0, 1.0, 1.0, 0.5);
Double_t a,b;
for (int i = 0; i < maxFill; i++) {
myTF2->GetRandom2(a,b);
myH->Fill(a,b);
}
myH->Draw("LEGO2");
myH->Fit("myTF2", "O");
myH->GetFunction("myTF2")->Draw("surf3 same");
There are two problems with this solution. First, the function is also plotted on the lego plot as a surface
and second, when rotating the view, the contours disappear if viewed from below
If I were to generalize this request, it would be to be able to plot one TH2 as a 3d plot (ability to choose lego, lego2, lego3, etc would be even better) and another one as a contour plot (with what ever contour options are available–cont, cont1, cont2, colz, etc) on the plane above the plot. This would allow one other switch the histogram and the function, for example.
Thanks for any pointers you have.
Paul


