Hello all,
I got a TH2F histogram, each bin of that represents energy in one cell in the detector. Is there a way to draw borders between bins to make a more clear distinction between them?
I know about TLine, but is seems quite unsuitable here to use it.
linev
January 24, 2022, 4:34pm
3
I do not think that such option exists, but @couet can correct me
couet
January 24, 2022, 4:58pm
4
It is not foreseen as an option. But it is simple to do :
void drawgrid()
{
double xs = 0.2; // grid step along X
double ys = 0.2; // grid step along Y
double xmin,ymin,xmax,ymax;
gPad->GetRangeAxis(xmin,ymin,xmax,ymax);
auto aline = new TLine();
aline->SetLineStyle(3);
for (double yg = ymin+ys; yg < ymax; yg=yg+ys) aline->PaintLine(xmin,yg,xmax,yg);
for (double xg = xmin+xs; xg < xmax; xg=xg+xs) aline->PaintLine(xg,ymin,xg,ymax);
}
void customgrid()
{
gStyle->SetOptStat(0);
auto h = new TH2D("h","",10,0,10,10,0,10);
h->Draw();
h->GetXaxis()->SetRangeUser(2,8);
gPad->Update();
auto grid = new TExec("grid","drawgrid()");
grid->Draw();
}
1 Like
system
Closed
February 7, 2022, 4:59pm
5
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.