Hello,
Is it possible to designate a bin in a 1d histogram to have a different
fill colour to the others ? ( eg. say, one bin red, in a white filled histo ).
Regards,
Kyle Stevenson.
couet
2
// File bincolor.C
void PaintBin (TH1 *h, Int_t bin, Int_t color)
{
printf("%d %d %d\n", bin, color, h->GetBinContent(bin));
TBox *b = new TBox(h->GetBinLowEdge(bin),
h->GetMinimum(),
h->GetBinWidth(bin)+h->GetBinLowEdge(bin),
h->GetBinContent(bin));
b->SetFillColor(color);
b->Draw();
}
void bincolor()
{
TH1F *h1 = new TH1F("h1","h1",100,-10,10);
h1->FillRandom("gaus");
h1->Draw();
PaintBin (h1, 60, kRed);
PaintBin (h1, 50, kBlue);
}
Thankyou,
This is almost ok for what I want but there are problems with the
minimum ( the y-minimum is set to the lowest entry rather than the
y-axis minimum ). Also how would I avoid over-writing the lines of the x-
axis ?
Cheers,
Kyle.
couet
4
Can you send a small macro reproducing this effect ?
Hello,
I've included the macro & root file I'm using. Should run ok out the box.
Cheers,
Kyle.
ps. I’m on ROOT v5.22/00b
Results.root (33.6 KB)
turnoncurves.c (3.43 KB)
brun
6
see your macro modified in attachment.
Look at the 2 lines with //<=========
and the line h->GetMinimum() replaced by gPad->GetUymin().
Rene
turnoncurves.C (3.51 KB)