I am using g++. How can i draw some TH2F and then write them to a file output (not to screen)? I want to write multiple plots to an output *.root file.
File3->cd();
CPlot->Draw("colz text15e");
gPad->SetLogz();
CPlot->Write();
This doesn’t seem to work. What am I doing wrong?
Hi,
This should work. Could you post a complete (running) example showing the problem?
Cheers, Bertrand.
[quote=“bellenot”]Hi,
This should work. Could you post a complete (running) example showing the problem?
Cheers, Bertrand.[/quote]
I think I got the formatting to work. I had to print the canvas, not the histogram.
CPlot->Draw("colz");
gPad->SetLogz();
cnvfname << "cc_" << k2 << "_" << estart << ".pdf";
cnvfilename = cnvfname.str();
N1->Print(cnvfilename.c_str());
I’m a bit confused here… Now you save in a .pdf file, but before you asked for a .root file…
Is there a way to write them to a root file in graphic form?
[quote=“cecoppola”]Is there a way to write them to a root file in graphic form?[/quote]Indeed, you can save the canvas, or the histograms, or even both…
[quote=“cecoppola”]
cnvfname << "cc_" << k2 << "_" << estart << ".pdf";
cnvfilename = cnvfname.str();
N1->Print(cnvfilename.c_str());
[/quote]
If you want to save lines you may also use TString::Form():
root.cern.ch/root/html/TString.html#TString:Form