How to set the exact TCanvas size?


I think I don’t fully understand one of the constructor of a TCanvas.

Try this:

	Double_t x, y;
	TCanvas * c = new TCanvas("canvas", "window", 500, 500);
	TH2D * h = new TH2D("h", "Title;x;y", 50, -5, 5, 50, -5, 5);

	for (Int_t i = 0; i < 1E+4; i++) {
		gRandom->Rannor(x, y);
		h->Fill(x, y);

	return c;

I’d expect that the test.png image is exactly 500x500 pixel, because those are the numbers I set in the TCanvas. Why I get 498x474? It’s not even a square.

How do I need to edit that macro in order to get output images with exactly the size I want?


Search for “size” in the TCanvas Class Reference.

1 Like

That was easy…


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