Stairs graph from text file

Hello,
I want to plot a stairs or step graph from the 2 column text file.
I am not able to find Draw option for stairs graph.
The simple program that I am using is :slightly_smiling_face:

FILE *fpm = fopen("Mass_Energy.txt", "r");

   int i=0;
   double a,b;

   TGraph *ab = new TGraph();

   while (fscanf(fpm, "%lf\t%lf", &a, &b)!=EOF) {
      i++;
      ab->SetPoint(i,a,b);
   }
   ab->SetMarkerStyle(21);   //21 for solid square, 20 for solid circle
   ab->Draw("P");

Hopefully, I need to make some changes to the Draw option.

ROOT Version: 6.14/04
Platform: Ubuntu 18.04 LTS


It seems you are looking for an historgam not a graph.
If you really need a graph you will have to insert the extra points making the stair and draw with option L.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.