[ROOT] Question

From: Marieke Navin (M.Navin@sheffield.ac.uk)
Date: Fri Mar 05 2004 - 09:42:48 MET


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");
}

-- 
--------------------------------------------------------------------
| Miss Marieke Navin                          wk:+1142223553       |
| Particle Physics and Particle Astrophysics  fx:+1142728079       |
| Department of Physics and Astronomy         mb:07919687122       |
| University of Sheffield                                          | 
| Hicks Building, Hounsfield Road                                  | 
| M.Navin@sheffield.ac.uk                                          |	
| Sheffield,                                                       |
| S3 7RH, United Kingdom                                           |
--------------------------------------------------------------------



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