Remove White Border from my graph

can someone tell me how to remove white border on that graph?

Hi @P_Renaldi,

Could you please give us more context / share a minimal reproducer? Otherwise, it’s impossible to help. FYI, @couet.

Cheers,
J.

so, the code like that

    TCanvas *cyz = new TCanvas("","", 1400,1000);
    TH2F *hyz = new TH2F("","", 231,-115.5,115.5, 141,-0.5,140.5);
    for(int j=1; j<=231; j++)
    for(int k=1; k<=141; k++)
    {
      float value = h3D->GetBinContent(i,j,k);
      hyz->SetBinContent(j,k,value);
    }
    hyz->DrawCopy("COLA");
    cyz->SaveAs(Form("%s.png",cyz->GetName()));

i try to put

    cyz->SetFrameLineColor(0);

after TH2F

but nothing change

then, i remove that line and trying to put

cyz->GetFrame()->SetLineColor(0);

after

hyz->DrawCopy("COLA");

and it doesnt give any change on my graph

Thanks. I’m sure @couet can help you with this :-).

h3D is not defined in your macro.

i define h3D, the code was

TH3F *h3D = new TH3F("h3D","h3D", 231,-115.5,115.5, 231,-115.5,115.5, 141,-0.5,140.5);

and then

h3D->SetBinContent(i,j,k,ratio);
  }

  double pBY  = 230.33;
  double pH = 138.75;

after that, the code was TCanva *cyz…

so, what should i do?

Can you send me the full new working code?

Error in <TFile::TFile>: file xxx.root does not exist
Error in <TFile::TFile>: file xxx_base.root does not exist

sorry, i dont have permission to give the data. i’ll try to figure it out. thanks for your help

Just provide a reproducer I can run.

Hi,

I guess, you need to set pad margins to 0 before creating TCanvas. Like:

gStyle->SetPadLeftMargin(0);
gStyle->SetPadRightMargin(0);
gStyle->SetPadTopMargin(0);
gStyle->SetPadBottomMargin(0);

See documentation of TStyle class

Regards,
Sergey

It works, thank you very much

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