Setting X and Y axis in TH2F

I am trying to assign calibration value to my axis on a 2D plot when plotting a TH2F.
I get the following error:

[color=red]Error in TCanvas::Range: illegal world coordinates range: x1=0.000000, y1=-312.500005, x2=0.000000, y2=312.500005
Error in TCanvas::RangeAxis: illegal axis coordinates range: xmin=0.000000, ymin=-250.000000, xmax=0.000000, ymax=250.000000[/color]

when I do the following operation

Hist->GetXaxis()->Set(4096,pXarrayEnergy); //Contains the calibration of my X axis

Am I miss-interpreting the usage of the Set function from TAxis?
Looking at the documentation, and as a note to my example, the following does work:

Hist->GetXaxis()->Set(4096,low_x, max_x);

Thanks for your inputs…

-----This is my code relevant
double pXarrayEnergy[CAPACITY2DMAX];
double pYarrayTime[CAPACITY2DMAX];

//Initializes the monster: A 2D array
t_data *pData2DArray[CAPACITY2DMAX];
for(int i=0;i<CAPACITY2DMAX;i++)
pData2DArray[i]=new t_data[CAPACITY2DMAX];

//pXarrayEnergy and pYarrayTime assing here… not included here

// Create Histogram
TH2F *Hist = new TH2F(“Hist”, “Test Contour”, 4096,0,4096, 4096,0,4096);
[color=red]//The following generates an error[/color][color=green]
Hist->GetXaxis()->Set(4096,pXarrayEnergy); //Contains the calibration of my X axis
Hist->GetYaxis()->Set(4096,pYarrayTime); //Contains the calibration of my X axis

// Load Histogram Data
for (Int_t i = 0; i < 4096; i++)
for(Int_t j = 0; j < 4096; j++){
Hist->SetBinContent(i,j, (int)pData2DArray[i][j]);


Thxs to post

My error was fixed by doing the following change:

Hist->GetXaxis()->Set(4095,pXarrayEnergy); //Contains the calibration of my X axis
Hist->GetYaxis()->Set(4095,pYarrayTime); //Contains the calibration of my X axis

My array size for pXarrayEnergy is 4096. However, when calling the Set function, I have to use 4095 instead to 4096. This small detail was not clear in the documentation. I would appreciate if somebody could clarify this…