Plot polar TH2

I do not know if it has been implemented yet. I worked out a solution for this long time ago and would post it here, may be helpful for other guys.

TCanvas * plot_histogram_in_polar(TH2D * h2d) {

  h2d->SetStats(false);
  TCanvas * can = new TCanvas("can", "", 600, 600);
  can->SetTheta(90);
  can->SetPhi(180);
  
  h2d->Draw("pollego2z");
  double ymax = h2d->GetYaxis()->GetXmax();
  double ymin = h2d->GetYaxis()->GetXmin();

  TGraphPolargram * gp = new TGraphPolargram("g",
                                             ymin, ymax,
                                             0, 2*TMath::Pi());
  gp->SetNdivRadial(4);
  gp->SetLineColor(17);
  gp->Draw();
  can->Update();
  
  TPaletteAxis *palette = (TPaletteAxis*)h2d->GetListOfFunctions()->FindObject("palette");
  palette->SetX1NDC(0.89);
  palette->SetX2NDC(0.92);
  palette->SetY1NDC(0.6);
  palette->SetY2NDC(0.97);
  palette->SetLabelSize(0.03);
  can->Modified();
  
  return can; 
}