Inserting logo or image

Dear Rootusers,

I want to insert a image or logo in my plots (canvas) by using in macros .
Could anyone please help me to know how to do it ?

Thank you,
Regards

Nihar

Look at the examples in $ROOTSYS/root/tutorials/image/

Hi,

Now i can insert it on my plotting canvas now.
I want to keep this logo at the top right or left of my plot.
Could you please help me what function or syntax i use to do it ?

Thank you.

You should plot it each time you draw a picture.
The best is to make a small macro which does the plot and then add the logo, like that you have only one command to type.

Hi,

Sorry…i am not getting your point.

As per your suggestions
i use

root -l 'XXXXX.C’
root [0]
Processing XXXXX.C…
root [1] TImage *img = TImage::Open(“yyy.jpg”);
root [2] img->Draw();

(is it the way your are suggesting ?)

But when i follow this, then whole logo is filled on the canvas and no plots are visible.
And i can’t resize it to put it on the top right or left.

Please, suggest .

Thank you.

I mean that you should embed in a macro the logo drawing and the histogram drawing to simplify the typing.
Can you send a small example showing what your are doing ?

Hi,

Here is my small macro

please, suggest.

void plot_image()
{

  TImage *img = TImage::Open("image.jpg");

  if (!img) {
    printf("Could not create an image... exit\n");
    return;
  }

  
  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("npart_ave","",1000,0.,1000.,900,-1.,8.);
  npart_ave->GetXaxis()->SetMoreLogLabels();
  npart_ave->GetXaxis()->SetNdivisions(-503);
  npart_ave->GetXaxis()->SetTitleOffset(1.1);
  npart_ave->GetYaxis()->CenterTitle(true);
  npart_ave->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");
  //img->SetConstRatio(0);
  //img->SetImageQuality(TAttImage::kImgBest);
   img->Draw();
 //img->SetEditable(kTRUE);
   c6->Modified();
   c6->cd();
   c6->SetSelected(c6);
}

Thank you.

See the attached files.


logo.C (1.45 KB)

Hi,

yes, it works now.

But how do i set the position of the logo pad on my plotting pad ?
just as our own desire place …because it can’t be dragged to desired place .
should i randomly choose the values in the TPad constructor for its position ?

Please, suggest.

Thank you .

Look at the macro drawing the logo, it creates a pad. This pad defines the logo position and size in normalized coordinates.