Re: [ROOT] Question

From: Olivier Couet (Olivier.Couet@cern.ch)
Date: Fri Mar 05 2004 - 12:55:09 MET


Hi,

 The two attached macros may help you (they come from the ROOT/tutorials):

 - twoscales.C to answer your question a)
 - graph.C for question b)

 For the point c) I guess you should just create a TLatex to label the 
lines.

 Cheers,       Olivier


On Fri, 5 Mar 2004, Marieke Navin wrote:

> 
> 
> Hello,
> 
> Would anybody mind having a quick look at this code and advising me of 
> how to:
> a) Plot another y axis on the right hand side with a different scale on it
> b) Label the x and y axes
> c) label the lines on the graph.
> 
> I have been trying commands such as inputspec->GetAxis()->SetTitle()
> axis1->SetName etc
> 
> Many thanks in advance.
> Here is the code:
> 
> 
> {
>   gROOT->Reset();                       // reset global variables
>   
>   gStyle->SetCanvasColor(10);
>   gStyle->SetTitleColor(10);
>   gStyle->SetFrameFillColor(10);
>   gStyle->SetOptStat(0);
>   
>   ifstream data;                        // declare a file to input from
>   data.open("led1.data");   // open file containing values
>   
>   const Int_t n = 100;                        // number of points to be plotted
>   Int_t in = 0;
> 
>   Float_t x[n], y1[n], y2[n];
>   Float_t x1;
> 
>   char line[1024];
>   while (data >> x1)
>     {
>       x[in] = x1;
>       data >> y1[in];
>       data >> y2[in];
>       in++;
>     }
> 
> 
>   for (Int_t i=0; i<in; i++)
>     {
>       cout << x[i] << " " << y1[i] << " " << y2[i] << endl;
>     }
>   
>   TGraph *inputSpec = new TGraph(in, x, y1);
>   TGraph *inputSpec2 = new TGraph(in, x, y2);
>   inputSpec->SetTitle("Intensity of LED 1");
> 
> 
>   TCanvas *c1 = new TCanvas("c1", "Intensity of LED 1",0,  0, 800, 600);  
>   c1->SetLogy();
>   
>   inputSpec->Draw("AC");
>   inputSpec2->Draw("CP");
> }
> 
> 

-- 
Org:    CERN - European Laboratory for Particle Physics.
Mail:   1211 Geneve 23 - Switzerland                     Mailbox: J25910      
E-Mail: Olivier.Couet@cern.ch                            Phone:   +41 22 7676522
WWW:    http://cern.ch/Olivier.Couet/                    Fax:     +41 22 7677155






This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:06 MET