This is a slight modification of a macro found on this forum some time ago, so all credit goes to the original author, couet:
void aa()
{
TGraph *g1 = new TGraph("aa.txt");
g1->SetMarkerStyle(20);
g1->SetMarkerColorAlpha(kBlue, 0.35);
g1->GetYaxis()->SetTitle("Y axis");
g1->GetXaxis()->SetTitle("X axis");
g1->SetMarkerSize(1);
g1->Draw("APL");
g1->GetXaxis()->SetLabelSize(0);
g1->GetXaxis()->SetTickLength(0);
Int_t i,n;
Double_t x,y;
TLatex *t;
TLine *tick;
TLine *grid;
double ymin = g1->GetHistogram()->GetMinimum();
double ymax = g1->GetHistogram()->GetMaximum();
double dy = (ymax-ymin);
n = g1->GetN();
for (i=0; i<n; i++) {
g1->GetPoint(i,x,y);
t = new TLatex(x, ymin-0.03*dy, Form("%4.3f",x));
t->SetTextSize(0.03);
t->SetTextFont(42);
t->SetTextAlign(21);
t->Draw();
tick = new TLine(x,ymin,x,ymin+0.03*dy);
tick->Draw();
grid = new TLine(x,ymin,x,y);
grid->SetLineStyle(3);
grid->Draw();
}
}
You can leave out the “grid” lines if not needed.
Edit - Original post: