Histogram Drawing Frame Size


Hello, I am plotting some 2d histograms and I would like the plot to be square. In other words, the x and y axes have the same range and bin width so I want that evident in the plot. As it stands, the drawing comes out rectangular. Here is the relevant code (in python):

import ROOT as R
R.gStyle.SetOptStat(0)

pn3 = R.TH2F("PN3", "CH3 Normalized", dimx, 0, dimx, dimy, 0, dimy)

#Skipped section of code where I fill the histogram

c1 = R.TCanvas()
pn3.Draw('colz')
c1.Draw()

The result is the following image:

As you can see, the x-axis is longer than the y-axis and thus the image is squished a little. I think the relevant object to edit is the TFrame but I could not find anything useful in the reference guide for editing it to keep it square. Any help is appreciated!

_ROOT Version: 6.12.06
Platform: Not Provided
Compiler: Not Provided


You should create you canvas square. Do not use the default dimensions.

The canvas cannot be square because it’s the “blue” plot (i.e. excluding axes labels, all titles and the color palette) which needs to be square.

ROOT forum -> search -> square aspect ratio

If right, top, left, and bottom margin are equal a square canvas will be fine. if not the pad size will have to be adapted to make sure the plot area is square.