Black background in PDF

Hi,

I’d like to know why this code produces the attached pdf with black regions. How do I fix it?

#include <TROOT.h>
#include <TStyle.h>
#include <TH1F.h>
#include <TCanvas.h>
#include <TGaxis.h>

void
test()
{ 
  gROOT->SetStyle("Plain");
  gStyle->SetPalette(1);
  gStyle->SetOptStat(111110);
  gStyle->SetOptFit(1);
  gStyle->SetHistMinimumZero();
  gStyle->SetFrameFillColor(kWhite);
  TGaxis::SetMaxDigits(3);

  TH1::SetDefaultSumw2();

  string filename = "plots/test";

  TCanvas*  canvas = new TCanvas("canvas", "canvas", 600, 700);
  bool canvasOpened = true;

  TH1F* h = new TH1F("h","ht", 100, -5, 5);
  h->FillRandom("gaus",10000);
  /*=======================================================================*/
  canvas->Clear();
  canvas->Divide(2);
  canvas->cd(1);
  h->Draw();

  canvas->cd(0);
  canvas->Update();
  canvas->Print((filename+".pdf(").c_str());
  canvas->Print((filename+".pdf").c_str());
  canvas->Print((filename+".pdf)").c_str());
  /*=======================================================================*/

  if (canvasOpened) canvas->Close();
}

Cheers,
N
test.pdf (25.1 KB)

What do you want to achieve with this macro ? The parenthesis mechanism is meant to produce several different pages in the same file. Here you have only one … that’s a bit weird. The normal way to use this mechanism would be:

{
   TFile f("hsimple.root","READ");
   c1 = new TCanvas("c1","sub data",200,10,700,500);
   hpx->Draw();
   c1->Print("h1.pdf(","pdf");
   hpx->Draw();
   c1->Print("h1.pdf","pdf");
   hpx->Draw();
   c1->Print("h1.pdf)","pdf");
} 

Hi couet,

That macro was just a demonstration of what I think is a bug.
In my real script I wanted to create a pdf with several pages, in which every page is a split into several pads. This macro shows that if you print a split-pad canvas onto a multiple-page pdf file, the first page is okay, but the rest have problems.

This is using 5.28. Can you see the same problem?

N.

Looks like the culprit is:
gROOT->SetStyle(“Plain”);

When leaving this out the pdf looks fine.

N.

It is more complex than that…

Note it is ok using PostScript.

I am looking…

If you plot something in the 2nd zone, it is also ok…
Still investigating…

This is now fixed in the SVN trunk.
Thanks for reporting.