Hi Drew,
We are planning to introduce a TH1::SetBinColor function (not in coming release
however).
In the coming release (not yet in CVS), you will be able to set bin colors via a
THStack of lego plots as shown in the example below:
Rene Brun
void legocol() {
TCanvas *c1 = new TCanvas;
Int_t nbins = 10;
TH2F *h1 = new TH2F("h1","h1",nbins,-4,4,nbins,-4,4);
h1->SetFillColor(kBlue);
TH2F *h2 = new TH2F("h2","h2",nbins,-4,4,nbins,-4,4);
h2->SetFillColor(kRed);
THStack *hs = new THStack("hs","two plots");
hs->Add(h1);
hs->Add(h2);
TRandom r;
Int_t i;
for (i=0;i<20000;i++) h1->Fill(r.Gaus(),r.Gaus());
for (i=0;i<20;i++) {
Int_t ix = r.Uniform(0,nbins);
Int_t iy = r.Uniform(0,nbins);
Int_t bin = h1->GetBin(ix,iy);
Double_t val = h1->GetBinContent(bin);
if (val <= 0) continue;
h1->SetBinContent(bin,0);
h2->SetBinContent(bin,val);
}
hs->Draw("lego1");
}
Andrew Baden wrote:
>
> I have a 2d histogram that I draw as a "lego". I'd
> like to set the color of individual cells. Specifically,
> this histogram might have a cell which has a value of 0
> for 2 different reasons, so I would like to change
> the color of the individual cell. How do I do this?
>
> Thanks,
> Drew Baden
> USCMS
> University of Maryland
> Drew Baden
> Associate Chair (whatever that is)
> Physics Department
> University of Maryland
> College Park, MD 20742
> 301-405-5947 (office)
> 6080 (lab)
> drew@umd.edu
This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:08 MET