Re: [ROOT] Plotting graph

From: Colin Bernet (bernet@kph.uni-mainz.de)
Date: Thu Feb 01 2001 - 15:37:11 MET


Hi Sam,

I modified your code below. This should work (but it's not tested !). A macro
is just C++, so you can also use C.
cheers,

Colin

#define MAX_POINTS 10000

> {
>    //
>    //
>    gROOT->Reset();

        Float_t x[MAX_POINTS],y[MAX_POINTS];

        // reading file
        FILE *datafile=fopen("data01.dat","r");
        Int_t n=0;
        while (fscanf(datafile,"%f%f",&x[n],&y[n]) ) {
                  n++;   // counting number of entries for the graph
                  if (n == MAX_POINTS) break;
        }


>
>    Float_t x0,x1;
>
>    c1 = new TCanvas("c1"," Graph ",200,10,700,500);
>
>    c1->SetFillColor(42);
>    c1->SetGrid();
>    c1->GetFrame()->SetFillColor(21);
>    c1->GetFrame()->SetBorderSize(12);

>    gr = new TGraph(n,x,y);
>    gr->SetMarkerColor(4);
>    gr->SetMarkerStyle(21);
>    gr->Draw("AP");
>
>    c1->Update();
>

        fclose(datafile);

> }
>
> Cheers, Sam.

--
-------------------------------------------------------------
   Colin Bernet
   Tel. +49-6131/39-23192          Fax  +49-6131/39-22964



This archive was generated by hypermail 2b29 : Fri Jun 08 2001 - 11:50:59 MEST