Hi Pete,
An example:
void h2a() {
//create a 2-d array of histograms and draw it
const Int_t NX=6, NY=4;
TH1F *h1[NY][NX];
Int_t i,j,k=0;;
char hname[20];
for (j=0;j<NY;j++) {
for (i=0;i<NX;i++) {
sprintf(hname,"h%d_%d",j,i);
h1[j][i] = new TH1F(hname,"test",10,-4,4);
h1[j][i]->SetFillColor(38);
h1[j][i]->SetStats(0);
}
}
TCanvas *c1 = new TCanvas("c1");
c1->Divide(NX,NY);
for (j=0;j<NY;j++) {
for (i=0;i<NX;i++) {
h1[j][i]->FillRandom("gaus",100);
k++;
c1->cd(k);
h1[j][i]->Draw("bar2");
}
}
}
Rene Brun
On Mon, 22 Apr 2002, Peter Karpius wrote:
> Hello!
>
> I am new to this list and new to Root and C++ in general so please
> forgive my ignorance. Anyway, I need to fill a canvas with a 2D array of
> histograms. I followed a previous thread to create the histograms and
> this seemed to work. Now I am trying to Draw them with a set of nested
> loops preceded by a canvas division to match the array dimienions. It
> seems that only the last histgram gets drawn overiting the previous ones.
> I know this is a simple problem but I am stuck.
>
> Are there any examples of multidimensional histograms using Draw()?
>
> Thanks!
>
> Pete Karpius
>
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:51 MET