Dan,
You can use the THStack class. See an example in the attachement
Rene Brun
Dan Holmes wrote:
>
> ah, sorry, i want to be able to actually define the colour (hi-lite) of
> one or two of my bars....but i like the overall style of lego1. I have
> looked at the manual/tutorials but i can't see any obvious way of doing
> it..
>
> On Thu, 3 Apr 2003, Rene Brun wrote:
>
> > Hi Dan,
> >
> > Use option "lego2" or "col" instead of 'lego1"
> >
> > Rene Brun
> >
> > Dan Holmes wrote:
> > >
> > > Hello,
> > >
> > > i have a TH2D, 5x5 plotting in lego. I would like to be able to message
> > > individual bins (columns) to make them different colours.
> > >
> > > Here is the code i have to make it so far, can you suggest how i might
> > > modify it?
> > >
> > > //make it:
> > > TH2D *XtalsLego=new TH2D("energy In 25 xtals for all events","Matrix of 25
> > > Xtals, normed Log En deposited",5,0,5,5,0,5);
> > >
> > > //fill it:
> > > for (int i=1;i<6;i++){for (int j=1;j<6;j++){
> > > Float_t xXtal=i-0.5;
> > > Float_t yXtal=j-0.5;
> > >
> > > int myIndex=j+2+(i+1)*10;
> > > Double_t someEn=energyDeposited[myIndex]+this->Noise();
> > > XtalsLego->Fill(xXtal,yXtal,someLogEn);
> > > }}
> > >
> > > //draw it:
> > > TCanvas *myCanv=new TCanvas("big dog ","EnDep in 25 Xtals",1);
> > > myCanv->SetFillColor(42);
> > > gStyle->SetFrameFillColor(40);
> > > XtalsLego->SetFillColor(38);
> > > XtalsLego->Draw("lego1");
> > >
> > > --
> > >
> > > CMS-Bristol
> > > http://cern.ch/dan.holmes
> >
>
> --
>
> CMS-Bristol
> http://cern.ch/dan.holmes
{
//make it:
TH2D *h1=new TH2D("h1","Matrix of 25 Xtals, normed Log En deposited",5,0,5,5,0,5);
TH2D *h2=new TH2D("h2","Matrix of 25 Xtals, normed Log En deposited",5,0,5,5,0,5);
TH2D *h3=new TH2D("h3","Matrix of 25 Xtals, normed Log En deposited",5,0,5,5,0,5);
//fill it:
for (int i=1;i<6;i++){for (int j=1;j<6;j++){
Float_t xXtal=i-0.5;
Float_t yXtal=j-0.5;
Double_t someEn=gRandom->Uniform();
if (i==2 && j == 2) {
h2->Fill(xXtal,yXtal,2);
} else if (i ==3 && j==3) {
h3->Fill(xXtal,yXtal,3);
} else {
h1->Fill(xXtal,yXtal,someEn);
}
}}
//draw it:
TCanvas *myCanv=new TCanvas("big dog ","EnDep in 25 Xtals",1);
myCanv->SetFillColor(42);
gStyle->SetFrameFillColor(40);
h1->SetFillColor(38);
h2->SetFillColor(42);
h3->SetFillColor(50);
THStack *hs = new THStack("hs","test");
hs->Add(h3);
hs->Add(h2);
hs->Add(h1);
hs->Draw("lego1");
}
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:10 MET