Draw a TH1 on the center of a TH2Poly bin

Hi,

I would like to know how to draw a TH1 on the center of a TH2Poly bin.

The TH2Poly is created as follows:

  auto c = new TCanvas("c","",800,1000);
  TH2Poly *hc = new TH2Poly();
  hc->SetTitle(";x [mm];y [mm]");
  hc->Honeycomb(0,0,TMath::Sqrt2(),4,3,"h");
  hc->SetStats(0);
  hc->Draw("L");
  gPad->Modified(); gPad->Update();
  gPad->GetFrame()->SetLineColor(0);
  c->SetRealAspectRatio(1);


Thanks a lot!


Please read tips for efficient and successful posting and posting code

Please fill also the fields below. Note that root -b -q will tell you this info, and starting from 6.28/06 upwards, you can call .forum bug from the ROOT prompt to pre-populate a topic.

ROOT Version: 6.31/01
Platform: Linux
Compiler: GCC 9.3.0


Check out the transpad.C tutorial. Also found online. Just adjust the position and size of the transparent pad for your case.

Thanks.
What if I need to draw on each bin center of the TH2Poly? Is there an easier way to get the positions?

You will need to do the computation yourself.
You can try to divide the canvas with Divide().
But surely some adjustments will be needed.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.