Plotting from text file

Dear Experts,

I want to plot from a text file having two columns. In one column KPt values and in other column, FOM values are saved. I want to plot FOM in Y-axis and KPt in X-axis. I am attaching the text file.kpt.txt (457 Bytes)

$ root
   ----------------------------------------------------------------
  | Welcome to ROOT 6.09/03                    http://root.cern.ch |
  |                                   (c) 1995-2017, The ROOT Team |
  | Built for macosx64                                             |
  | From heads/master@v6-09-02-886-ga41483a, May 17 2017, 16:59:49 |
  | Try '.help', '.demo', '.license', '.credits', '.quit'/'.q'     |
   ----------------------------------------------------------------

root [0] auto *g = new TGraph("kpt.txt");
root [1] g->Draw("AL");

Hi Couet,

It is showing error and the error is shown below.

root [0] auto *g = new TGraph("kpt.txt");
Error: Undeclared variable g (tmpfile):1:
*** Interpreter error recovered ***

Thanks,
Deepak

do:

TGraph *g = new TGraph("kpt.txt");

the auto syntax is for ROOT 6 only.

Hi Couet,

Thanks, it’s working. I want to know, if there will two more(S and B) columns in the text file and I need to draw KPt vs S and KPt vs B. How will I do?

Thanks,
Deepak

kpt.txt (851 Bytes)
dsahoo.C (292 Bytes)

Hi Couet,

I want to draw the plots with a range for X-axis and Y-axis.

Thanks,
Deepak

https://root.cern.ch/how/how-set-ranges-axis

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