Two TGraph with 2 axis are a little bit shifted

Hello, following transpad.C example to plot two graphs with two different axis on the same figure.
I use the following margins in my rootlogon.C

ildStyle->SetPadBottomMargin(0.14); ildStyle->SetPadTopMargin(0.02); ildStyle->SetPadRightMargin(0.15); ildStyle->SetPadLeftMargin(0.12);
From the transpad.C example, I adapted the following lines

//compute the pad range with suitable margins Double_t ymin = 0; Double_t ymax = 2000; Double_t dy = (ymax-ymin)/0.8; //10 per cent margins top and bottom Double_t xmin = -3; Double_t xmax = 3; Double_t dx = (xmax-xmin)/0.8; //10 per cent margins left and right pad2->Range(xmin-0.1*dx,ymin-0.1*dy,xmax+0.1*dx,ymax+0.1*dy); by

//compute the pad range with suitable margins Double_t ymin = 1.35; Double_t ymax = 1.55; Double_t dy = (ymax-ymin)/0.84; Double_t xmin = 26.1881; Double_t xmax = 67.8044; Double_t dx = (xmax-xmin)/0.73; pad2->Range(xmin-0.12*dx,ymin-0.14*dy,xmax+0.15*dx,ymax+0.02*dy);
It almost works but I observed a little shift between the data on the second TGraph and the axis on the first pad (first point of the red data should be exactly at 30 and the last point exactyl at 64 ; if you take a crosshair, you see that it is not exactly the case)

I attached my rootlong.C and my C routine which plots the figure if you want to have a look.

Thanks in advance.
YZplusNoZ.C (7.88 KB)
rootlogon.C (2.53 KB)
YZplusNoZ.eps (12.5 KB)

It would be nice if you can reduce your example to some simpler just showing may be one point.
That’s what I will need to do any way…

I have simplified your macro to the one attached. Seems to me it is fine.
transpadmargin.C (2.11 KB)

Hmmm, in fact I should reformulate my request. I attached a new macro which contains two TGraph with only one point and the problem is not there anymore. In fact the problem in the previous macro comes from the xmin and xmax values. How can I know precisely the value of xmin and xmax used in the first pad to use them in the second pad?
Maybe something with g->GetXaxis()->GetXmin(). I try and I come back.
YZplusNoZ.C (2.25 KB)

Yes

Indeed, it was the problem. In my first macro, if I put

xmin = gre->GetXaxis()->GetXmin(); xmax = gre->GetXaxis()->GetXmax();
it works fine, I do not have this shift anymore.
Thanks for your help.