Dear Marieke, You wrote: > Can anyone offer advice for my simple graph? I have 3 columns of data: x, > y1 and y2. I want to plot x versus y1 and x versus y2 (dashed line) on > the same graph but at present it's only plotting the a versus y1. I know > it's something simple, My 2 cent to Rene's explanation. You can read data points with TGraph::TGraph(const char *filename, const char *format = "%lg %lg) constructor. inputSec = new TGraph("width_6face.dat"); inputSec2 = new TGraph("width_6face.dat", "%lg%*lg%lg"); -- Maxim Nikulin > ------------------------------------------------------------------------ > > // code for plotting Optical Beacon pulse widths graphs > > // Marieke Navin - September 2004 > > { > gROOT->Reset(); // reset global variables > > gStyle->SetCanvasColor(10); > gStyle->SetFrameFillColor(10); > gStyle->SetOptStat(0); > > ifstream data; // declare a file to input from > data.open("width_6face.dat"); // open different files containing values > > > //const Int_t n = 25; // number of points to be plotted > const Int_t n = 6; > //careful with no of points! > > Float_t x[n], y1[n], y2[n]; > > > for(Int_t i=0;i<n;i++){ > data>>x[i]>>y1[i]>>y2[i]; > } > > for (Int_t i=0; i<n; i++) > { > cout << x[i] << " " << y1[i] <<" " << y2[i] << endl; > } > > TGraph* inputSpec = new TGraph(n, x, y1); //change for title as necessary > TGraph* inputSpec2 = new TGraph(n, x, y2); > > > inputSpec->SetTitle("Amplitude measured on internal and external PMTs (6 Faces 15/465)"); > inputSpec->GetXaxis()->SetTitle("Angle (degrees)"); > inputSpec->GetYaxis()->SetTitle("Amplitude (mV)"); > > inputSpec->SetName("6face"); > inputSpec->Draw("AC"); > > inputSpec2->SetLineStyle(kDashDotted); > inputSpec2->Draw("CP"); > } > > > ------------------------------------------------------------------------ > > 0 7.02 6.38 > 10 7.04 6.38 > 20 7.03 6.38 > 30 7.04 6.40 > 40 7.05 6.40 > 50 7.06 6.42
This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:09 MET