Pyroot different graphic behavior in batch mode

Hi,

I have a module producing (and saving) some plots. The plots from batch mode (-b) look different from those from interactive mode when saved as .gif, .jpg and .tiff. Main differences are the size of the (tgraph) markers and the style of the lines. When saving as .ps however, the result is the same for both interactive and batch.

I don’t know if this is a pyroot issue (did not try with pure root). Is there a fix… or at least an explaination?

Regards,

Jean-Francois

Jean-Francois,

I’d be surprised if the difference is due to python (and hence you may get better feedback on the general support forum). However, the minimum for providing help would be a script to show the problem?

Cheers,
Wim

Hi Wim,

Here is a code example:

import ROOT

mygraf = ROOT.TGraph(5)
mygraf.SetPoint(0,1,1)
mygraf.SetPoint(1,2,1)
mygraf.SetPoint(2,3,1)
mygraf.SetPoint(3,4,1)
mygraf.SetPoint(4,5,1)

mygraf.SetMarkerStyle(20)
mygraf.SetMarkerColor(ROOT.kBlue)
mygraf.SetLineStyle(2)
mygraf.SetLineWidth(3)

c = ROOT.TCanvas('mycanvas', 'mycanvas')

mygraf.Draw('Alp')
c.Print('mycanvas.gif', 'gif')

If I run it in normal mode, I get a nice looking results (cf. attachement mycanvas.gif). If I run it in batch (-b) mode, it looks ugly (cf. attachment mycanvas_b.gif).

Are settings different in batch mode and interactive mode? I agree that this is probably not a pyroot problem since the results are the same when I save in ps format. Sorry for squatting the pyroot forum.

Regards,

Jean-Francois




Jean-Francois,

the example that you provided is trivially turned into a .C one to run with root.exe:

#include "TGraph.h"
#include "TCanvas.h"

void testgraph() {
   TGraph mygraf = TGraph(5);
   mygraf.SetPoint(0,1,1);
   mygraf.SetPoint(1,2,1);
   mygraf.SetPoint(2,3,1);
   mygraf.SetPoint(3,4,1);
   mygraf.SetPoint(4,5,1);

   mygraf.SetMarkerStyle(20);
   mygraf.SetMarkerColor(kBlue);
   mygraf.SetLineStyle(2);
   mygraf.SetLineWidth(3);

   TCanvas c = TCanvas("mycanvas", "mycanvas");

   mygraf.Draw("Alp");
   c.Print("mycanvas.gif", "gif");
}

and yes, it has the exact same behavior. Either file a bug report on savannah or ask the experts on the general support forum, as this is outside my expertise …

Cheers,
Wim

Jean-Francois,

I’m wondering if you were able to fix this. I’m currently seeing the same thing when I use batch mode (which I need to to do to avoid a weird ROOTX11 error). Interestingly, I’m also using pyroot. It looks like the default styles are different once batch mode is activated. Before hard-coding the styles I want, like the dot and the line, I was looking around the forum for similar things in the past and came across your post.

-Jay

void testgraph() {
   auto g = new TGraph();
   g->AddPoint(1,1);
   g->AddPoint(2,1);
   g->AddPoint(3,1);

   g->SetMarkerStyle(20);
   g->SetMarkerColor(kBlue);
   g->SetLineStyle(2);
   g->SetLineWidth(3);

   auto c = new TCanvas();

   g->Draw("Alp");
   c->Print("testgraph.gif");
}

Gives a slightly different line rendering in the png file depending if you run it in batch or interactively. It is because when you render it interactively a direct screen dump is done whereas when you do in batch a complete different rendering backend is used (libAfterImage) that explain the small different. You can use pdf instead. In that case the same backend is used in both cases.