Logos in plots with vector output as a style

Howdy folks. I’ve been trying to create a series of plots for an analysis and would like to include a logo in the corner of each plot (usually TH1s on a standard TCanvas).

@couet I found the tutorial here and hundreds of other root mailing list posts on the topic but couldn’t find a good answer.

  1. what’s the recommended way to add logos to a plot? - is the clunky pad interface the only way?
  2. How do I output said plots as .pdfs ? - I get a Warning in <TASImage::Paint>: PDF not implemented yet error, same as those mailing list posts from 2007.
  3. Is there a way of setting this as default like a style, such that I call a function set_logo and my current pad gets a logo and fonts etc are set? - currently I have to do this 10 times for the 6 sub plots on a canvas and 4 on the next.

Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


I have this example.

void DrawLogo(){

   TImage *img = TImage::Open("CernLogo.gif");

   if (!img) {
      printf("Could not create an image... exit\n");
      return;
   }
   TPad *l = new TPad("l","l",0.,0.9,0.1,1.);
   l->Draw();
   l->cd();
   img->Draw();
}

void logo()
{
   TCanvas *c6 = new TCanvas("c6", "S*#sigma",320,22,691,653);
   gStyle->SetOptStat(0);
   c6->Range(-0.3373713,-2.125,3.036341,9.125);
   c6->SetFillColor(0);
   c6->SetBorderMode(0);
   c6->SetBorderSize(2);
   c6->SetLogx();
   c6->SetFrameBorderMode(0);
   c6->SetFrameBorderMode(0);

   Float_t Y[4]={4.6,2.1,3.9,1.0  };
   Float_t X[4]={150.,26.,9.8,6.6};
   Float_t Yerr[4]={0.24,0.746,0.5809,1.29};
   Float_t Xerr[4]={0.0};

   TGraphErrors *hm3sta = new TGraphErrors(4,X,Y,Xerr,Yerr);
   gStyle -> SetCanvasBorderMode(0);
   gROOT->SetStyle("Plain");
   gStyle->SetOptStat(0);

   TH2F *h2 = new TH2F("h2","",1000,0.,1000.,900,-1.,8.);
   h2->GetXaxis()->SetMoreLogLabels();
   h2->GetXaxis()->SetNdivisions(-503);
   h2->GetXaxis()->SetTitleOffset(1.1);
   h2->GetYaxis()->CenterTitle(true);
   h2->GetYaxis()->SetNdivisions(40603);

   h2->GetXaxis()->SetTitle("X-axis");
   h2->GetYaxis()->SetTitle("Y-axis");
   h2->GetXaxis()->SetTitleOffset(1.1);
   h2->GetYaxis()->SetTitleOffset(1.2);
   h2->Draw();

   hm3sta->SetMarkerStyle(25);
   hm3sta->SetMarkerColor(2);
   hm3sta->SetLineColor(6);
   hm3sta->SetMarkerSize(2.0);
   hm3sta->Draw("P");
   DrawLogo();
}

Hi @couet yup this is basically the setup I have. if you try to save this canvas as a pdf I would assume you get the error I posted above.

Saving a canvas as a PDF is essential to this project.

PDF does not have the binary images implemented you can save to PS only.

Ah this works, thanks!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.