Re: [ROOT] Question

From: Marieke Navin (M.Navin@sheffield.ac.uk)
Date: Fri Mar 05 2004 - 16:55:53 MET


Could you be a bit more explicit at all? I already have the graph.C and 
twoscales.C but I cannot get the commands to work. Could you advise me as 
to the modifications I need to do to this code for my own code? the 
->Getaxis()->SetTitle doesn't work for me at all. Additionally the two 
scales is for histograms and I don't know how to modify this for my 
graph.I have commented out the commands I have been trying.
Thanks again in advance
Marieke


{
  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");
  // inputSpec2->GetXaxis()->SetTitle("Cos Theta");
  // inputSpec->GetYaxis()->SetTitle("pJ/pulse/sr");

  TCanvas *c1 = new TCanvas("c1", "Intensity of LED 1",0,  0, 800, 600);  
  c1->SetLogy();
  
  // trying to label x axis(doesnt work): inputspec->GetXaxis()->SetTitle("Cos Theta");

  //trying to draw axis on right here:
  //c1->Range(-10,-1,10,1);  
  // TGaxis *axis1 = new TGaxis(-9,-0.8,-9,0.8,0,1e5,50510,"");
  //axis1->SetName("axis1");
  //axis1->SetTitle("pJ/pulse/sr");
  //axis1->Draw();
  //TGaxis *axis2 = new TGaxis (7,-0.8,7,0.8,0,5e22,50510,"-G");
  //axis2->SetName("axis2");
  //axis2->SetTitle("number of photons/pulse/sr");
  //axis2->Draw();

  //trying to label x axis here:
  // TGaxis *axisx = new TGaxis();
  //axisx->SetName("axisx");
  //axisx->SetTitle("Cos Theta");
  


  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