Draw a grid for a TH2 with variable bin width

Hello,

is there an easy way to draw a grid that will match the bin edges in a 2D histogram having variable bin widths? It seems that the only control is over the number of divisions, and not on their positions.

Thank you,

Philippe

This is not possible because you have variable bin sizes along X OR/AND Y

Rene

is it possible then to draw arbitrary lines in TH2 from specific coordinates?

Thank you,
Philippe

see example below

void lines() { const Int_t nxbins = 8; Double_t xbins[nxbins+1] = {-3,-1,-0.5,-0.2,0,0.2,0.5,1,3}; TH2F *h = new TH2F("h","test",nxbins,xbins,40,-3,3); TRandom r; for (Int_t i=0;i<10000;i++) { h->Fill(r.Gaus(0,1),r.Gaus(0,1)); } TCanvas *c1 = new TCanvas("c1"); h.Draw(); //superimpose lines at the xbins positions TLine l; c1->Update(); Double_t ymin = c1->GetUymin(); Double_t ymax = c1->GetUymax(); l.SetLineStyle(2); for (Int_t bin=1;nxbins-1;bin++) { l.DrawLine(xbins[bin],ymin,xbins[bin],ymax); } }

Rene