Variable bin size of histogram

I added a variable bin size to my histogram though it gives variable bin size it shift my entire histogram to right,
I have tried the both ways but same shift in histogram occurs.

Double_t binEdges[ ] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130,140,150,160,170,180,190,200 };
Int_t NumBins = 47;
TH1D* hist = new TH1D("hist", "",NumBins, binEdges);
Double_t edges[] = {0., 1., 2., 3., 10., 20., 30., 200., 225., 250.};
const Int_t NBINS = sizeof(edges) / sizeof(Double_t) - 1;
TH1D *hist = new TH1D("hist", "", NBINS, edges);

Thank You for help.

Both ways are correct and there should be no artificial “shift”.

BTW. Note that ‘’’ is not the same as ```

Thank you for such quick response,
I couldn’t figure out the problem, I get the fine histogram with regular bin size but as I use variable bin size the plot shift to right.

That’s normal in these cases. In your “variable bin size” histograms, bins with bigger “bin number” have larger “bin width” (so they will “collect” more entries when filling).