# TH2D odd binning behaviour

Hi,

I am trying to fill a TH2D like this:

void plotit(){
vector xvals;
vector yvals;
for(int i=0; i!=10; i++){
double tx=static_cast(i+1);
double ty=static_cast(i+2);
xvals.push_back(tx);
yvals.push_back(ty);
}

TCanvas* can00 = canvas(“canvas”, 600, 600);

TH2D* h_kw = new TH2D(“kw”,“w mass mean as f(Rval)”,10,0.,15.,10,0.,15);
for(int p=0; p!=10;p++){
cout<<“xval[”<<xvals[p]<<endl;
cout<<“yval: “<<yvals[p]<<endl;
h_kw->Fill(xvals[p],yvals[p]);
}
h_kw->DrawCopy(””);
h_kw->SetMarkerStyle(20);
can00->Print(“daft.pdf”);
}

TCanvas* canvas(char* name, double xsize=500, double ysize=500) {
TCanvas* tc = new TCanvas(name, name, xsize, ysize);

tc->SetGridy(0);
tc->SetGridx(0);

return tc;
}

I have attached the plot I get when I do this. I am probably being dense, please advise me if this is so.

Thanks

Lily
daft.pdf (12.8 KB)

What you get is what you asked for (bin width=1.5 !).
Change

```TH2D* h_kw = new TH2D("kw","w mass mean asf(Rval)",10,0.,15.,10,0.,15); ```to

```TH2D* h_kw = new TH2D("kw","w mass mean asf(Rval)",15,0.,15.,15,0.,15); ```
Rene