Hi,
Can you send a running example reproducing your problem ? What you sent cannot be run "as is"...
Thanks, Olivier Couet
Hello all,
I am trying to save graphs and histograms to a root file. The histograms are saved correctly, but the graphs are not. Here is how I do it:
TCanvas *myc = new TCanvas("myc","Slice Test Data",0,0,760,480);
myc->SetTickx();
myc->SetTicky();
// Define a root file in which to save graphs and histograms.
TFile *hfile = gROOT->FindObject("test.root"); if (hfile)
hfile->Close(); hfile = new TFile("test.root","RECREATE","For graphs
and corresponding histos");
TH1F *sum6 = new TH1F("sum6","Sum 6 histogram",100,6e4,1e4);
sum7->SetFillColor(48);
gr = new TGraph(n, tmparray, myarray[5]);
gr->SetLineColor(colornb[2]); gr->SetMarkerColor(colornb[2]); gr->SetMarkerStyle(8); gr->SetMarkerSize(0.3); gr->SetTitle("Sum 6"); gr->GetXaxis()->SetTitle("Time [s]"); gr->GetYaxis()->SetTitle("Reading"); gr->Draw("APL"); gr->Write("Sum 6");
// fill and draw the histogram
int value =0;
for (int i=0; i<lines; i++) {
if(myarray[5][i]!=0) {
value = myarray[5][i]; sum6->Fill(value);
}
}
sum6->Draw();
hfile->Write();
myarray[][] is a 2D array of the data I am graphing/plotting. With the
above code, the histogram is saved correctly and I can open them with
TBrowser and view its contents. The graph is present in the root file
but it is empty when I try to view it. How do I do this properly?
Thanks,
Jose. Received on Sun May 13 2007 - 16:56:46 CEST
This message: [ Message body ]
Next message: Lorenzo Moneta: "Re: how to re-calculate error matrix in
TMinuit"
Previous message: X. Lu, Peking Univ.: "how to re-calculate error matrix
in TMinuit"
Contemporary messages sorted: [ by date ] [ by thread ] [ by subject ] [
by author ] [ by messages with attachments ]
This archive was generated by hypermail 2.2.0 : Sun May 13 2007 -
23:50:01 CEST
Received on Mon May 14 2007 - 10:23:18 CEST
This archive was generated by hypermail 2.2.0 : Mon May 14 2007 - 11:50:02 CEST