# Drawing several histograms with Divide()

**URL:** <https://root-forum.cern.ch/t/drawing-several-histograms-with-divide/2115>\
**Category:** ROOT\
**Created:** [July 5, 2005, 6:23pm UTC](https://root-forum.cern.ch/t/drawing-several-histograms-with-divide/2115 "2005-07-05T18:23:08Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![haefner](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/87869e/32.png) [@haefner](https://root-forum.cern.ch/u/haefner)\
**Post date:** [July 5, 2005, 6:23pm UTC](https://root-forum.cern.ch/t/drawing-several-histograms-with-divide/2115/1 "2005-07-05T18:23:08Z")

</div>

Hello,

Hope someone can help me with the following problems.

First Problem:  
I want to plot several histograms (4x3) into one Canvas without spaces between them. I’m using c1-\>Divide(4,3,0,0) for this, which works fine but the axis labels become very small. If I increase their size by  
hist-\>GetXaxis()-\>SetLabelFont(63);  
hist-\>GetXaxis()-\>SetLabelSize(15);  
so that they are readable they range over the canvas size.  
Does anyone know how to increase the left margin of the canvas so that the bigger labels and axis titles fit? SetLeftMargin for the canvas does’t work at all and if I specify a left margin only for the ‘left side’ pads they become smaller than the other ones (see attachments).

Second problem:  
Although I have the same range on the y-axis the tick marks of two adjacent histograms don’t fit. Any idea what’s wrong?

Third question:  
Is their a global canvas title or do only the pads have titles? I would like to give some global information about the data I’m plotting as a kind of headline.

Thanks in advance

Petra

Script:

void spr\_colz\_iso()  
{

gROOT-\>SetStyle(“Plain”);  
gStyle-\>SetPalette(1);  
gStyle-\>SetOptStat(1);  
gStyle-\>SetOptFit(1);  
gStyle-\>SetLineWidth(1);  
gStyle-\>SetTextFont(63);  
gStyle-\>SetTextSize(15);  
gStyle-\>SetLabelSize(20,“xy”);  
gStyle-\>SetLabelFont(63,“xy”);  
gStyle-\>SetOptTitle(0);  
// gStyle-\>SetTitleSize(5.0);  
// gStyle-\>SetLabelSize(5);  
gStyle-\>SetLineWidth(1);

//----------------------------------------------------------------------------  
// Total SPR in calorimeter parts  
//----------------------------------------------------------------------------

// gStyle-\>SetOptFit(1110);  
// gStyle-\>SetOptStat(0);

int num = 0;  
int iiso = 3;  
char histname[1000];  
char prjname[1000];

TCanvas \*SPRTotC = new TCanvas(“SPRTotC”,“SPR in em/fh/ch in CC/ICR/EC”,900,600);  
SPRTotC-\>Divide(4,3,0,0);

for (int ical = 0; ical \< 3; ical++)  
{  
for (int idet = 0; idet \< 4; idet++)  
{  
num++;  
SPRTotC-\>cd(num);  
gPad-\>SetTicks(1,1);  
sprintf(histname, “ha\_spr\_tot\_mu\_cal%d\_det%d\_iso%d”, ical, idet, iiso);  
TH2F\* hist = (TH2F\*)gROOT-\>FindObject(histname);  
hist-\>GetXaxis()-\>SetRangeUser(0.0,50.0);  
hist-\>GetXaxis()-\>SetNdivisions(205,0);  
hist-\>GetXaxis()-\>SetLabelFont(63);  
hist-\>GetXaxis()-\>SetLabelSize(15);  
hist-\>GetXaxis()-\>SetTitleFont(63);  
hist-\>GetXaxis()-\>SetTitleSize(15);  
hist-\>GetXaxis()-\>SetTitleOffset(1. ![8)](https://root-forum.cern.ch/uploads/default/original/1X/fe5f42ae79e389360ae9d969db4dcc4bca03d384.gif "Cool");

```
  hist->GetYaxis()->SetRangeUser(0.0,5.0);
  hist->GetYaxis()->SetNdivisions(205,0);
  hist->GetYaxis()->SetLabelFont(63);
  hist->GetYaxis()->SetLabelSize(15);
  hist->GetYaxis()->SetTitleFont(63);
  hist->GetYaxis()->SetTitleSize(15);
  hist->GetYaxis()->SetTitleOffset(2.5);
  SPRTotC->Update();
  hist->Draw("colz");
}

```

}  
}

 ![](https://root-forum.cern.ch/uploads/default/original/1X/566dce2d172eebe9a1db7deddb97e5ede0bd8b15.gif)  
  
 ![](https://root-forum.cern.ch/uploads/default/original/1X/5976aba254dbab8ff453ac34ff0218b96a79a8b3.gif)

---

_[View the full topic](https://root-forum.cern.ch/t/drawing-several-histograms-with-divide/2115)._
