Remove TCanvas border

how to remove the canavs border when the margins are small ?

Hi,

Could you share all the info to reproduce the behaviour (platform, root version, minimal code snippet…)?

Cheers,
D

The border you get is not a “Canvas border” but that’s the frame limits which appear to be close to the Canvas edges as your margins are small. You can remove it with canvas->SetFrameLineWidth(0);

It’s not the frame that’s the problem, adding this line produces the following situation where the top and right boundaries of the plot disappear but at the bottom and on the right the black boundary persists. I’ll work on producing a MWE that reproduces the issue

In that case it is clear to me which border you are talking about. Can you provide a small example reproducing your problem ?

here’s a mwe:

void MWE()
{
  TH1D *h = new TH1D("h","",100,-1,1);
  for (Int_t i = 0; i < 1000000; i++) h->Fill(gRandom->Gaus(0, 1));

  TCanvas *c = new TCanvas("c","c",900,700);
  h->Draw();
  c->SetLogy();
  c->SetMargin(0.071, 0.0044, 0.08, 0.019);
  c->SetBorderSize(0);
  c->Update();

  c->SaveAs("mwe.png");
}

It gives this, where you can see on the right and at the bottom a black kind of bevel border.

I think it doesn’t happen in the pdf (uploaded below)
mwe.pdf (14.1 KB)

Thanks I will check.

try:

root -b mwe.C

This works but the resolution is very low

Make A bigger canvas.
Without -b option the png file is generated using a screen dump of the displayed bitmap. It looks like so black line are added in that case. Note sure by whom because they do not show in PDF and PS and not when using batch mode . I batch mode TASImage is used.

ok thank you

You can also increase the definition using:

      gStyle->SetImageScaling(3.);