Box and same option in Draw();

Dear rooters,
I’m trying to draw several superimposed 2D histograms; I’m using the code at the end of the message in order to have a personal palette of colors instead of using TStyle::SetPalette. What happens is that the histograms are drawn empty. I noticed that other options are working, for example if I use “arr same” or “col same” or “text same” it works, but I need “box same” which seems to be the only not working. Am I making some kind of mistake or is it a bug?
Thanks!
Emiliano (for the PAMELA collaboration)

		    if ( estrip[l][m][n] > 0.7 ){
			Xview->SetFillColor(38);
			Yview->SetFillColor(38);
			if ( estrip[l][m][n] > 2. ){
			    Xview->SetFillColor(7);
			    Yview->SetFillColor(7);
			};
			if ( estrip[l][m][n] > 10. ){
			    Xview->SetFillColor(10);
			    Yview->SetFillColor(10);
			};
			if ( estrip[l][m][n] > 100. ){
			    Xview->SetFillColor(5);
			    Yview->SetFillColor(5);
			};
			if ( estrip[l][m][n] > 1000. ){
			    Xview->SetFillColor(2);
			    Yview->SetFillColor(2);
			};
			if ( l == 0 ) {
			    Xview->Fill(n,m,1.);
			    pd1->cd();				    
			    Xview->Draw("box same");
			    pd1->Update();
			};
			    
			if ( l == 1 ) {
			    Yview->Fill(n,m,1.);
			    pd2->cd();
			    Yview->Draw("box same");
			    pd2->Update();
			};
		    };

Can you send an example we can run showing your problem ?

Hi,
attached you will find an example. Sorry for the code which really has no sense but I had to take out of my program something can reproduce my problem without all the ancillars routines I use to call, calibrate, etc. etc. my data.
I’m using root version 4.01/02 24 September 2004, on a PC running Scientific Linux SL 3.0.2 (SL) . To run the example

.L example.c
CaloMATRA();

it will show two panels I’m trying to fill within 50 and 60. The lower oneis filled with text and you’ll see “1111…” in the correct position while the upper one should be filled with boxes in the same position but it isn’t in my case.
Thanks!
Emiliano
example.c (4.59 KB)

When you plot with “box same”, the previous histograms stored in the pad are checked to compute the minimum and maximum in order to have the correct box ratio over several plots. This example demonstrate that:

void boxsame() {
   c = new TCanvas("c","Example of BOX plots with option SAME",200,10,700,500);
   TH2F *h1 = new TH2F("h1","h1",40,-3,3,40,-3,3);
   TH2F *h2 = new TH2F("h2","h2",40,-3,3,40,-3,3);
   TH2F *h3 = new TH2F("h3","h3",40,-3,3,40,-3,3);
   TH2F *h4 = new TH2F("h4","h4",40,-3,3,40,-3,3);
   for (Int_t i=0;i<100000;i++) {
      double x,y;
      gRandom->Rannor(x,y);
      if(x>0 && y>0) h1->Fill(x,y,4);
      if(x<0 && y<0) h2->Fill(x,y,3);
      if(x>0 && y<0) h3->Fill(x,y,2);
      if(x<0 && y>0) h4->Fill(x,y,1);
   }
   h1->SetLineColor(1);
   h2->SetLineColor(2);
   h3->SetLineColor(3);
   h4->SetLineColor(4);
   h1->Draw("box");
   h2->Draw("box same");
   h3->Draw("box same");
   h4->Draw("box same");
}

I suspect that in your case there is no initial plot with the option “box” only, which leads to equal maximum and minimum values. Therefore you see nothing. In your example if you remove the “same” option you see a moving box which prove the " box" plot is working.

THANKS!
you’re right, what happen is what you say. In reality I plot the first time with the box option only but I’m drawing an empty histogram. As workaround I have filled a cell of the histogram before plotting it the first time with the box option only and then it worked prefectly!
Thanks again,
Emiliano