I have a PyROOT script which builds a canvas, then saves it to a C macro. When I run the macro, the canvas is correctly reconstructed save for the colors, which all default to:
Is there an equivalent way of doing this in PyROOT? I can’t figure out how to pass the correct argc and argv to the TApplication constructor in python. And looking at other posts, it looks like there’s a TPyROOTApplication; is that automatically created when you import ROOT, or is there some way to create an instance of that object?
Or am I going about solving this the complete wrong way?
For the record, here’s how I’m loading ROOT in my python script:
you can create your own TApplication with PyROOT, but to me it looks like a red herring. The difference in the scripts from the thread that you linked isn’t so much the TApplication (sure, that’s there as well), but primarily that the “failing” script (i.e. wrong colors) is run in batch and the “succeeding” script/program (i.e. correct colors) is not. I’ll bet that certain graphics objects need to be created that aren’t in batch.
int test() {
TCanvas *c2 = new TCanvas();
TH1F *hist = new TH1F(“hist”,“hist”,20,0,1);
hist->Fill(0.4);
hist->SetFillColor( kViolet );
hist->SetLineColor( kRed );
hist->Draw();
c2->Print(“printed.C”,“cxx”);
}[/code]
to compare the results of running not in batch and in batch:
ci = TColor::GetColor("#000000");
hist->SetLineColor(ci);
// …[/code]
The above is with CINT, so there is a TRint TApplication derived instance in both cases, the only difference being batch/no-batch. It’s also SVN trunk.