COLZ color index does not fit inside Canvas

If I print a 2D histogram into a “gif file”, with h2->Draw(“COLZ”), on the right of the histogram there will be a Color Index, with numbers indicating the values corresponding to the colours.
This scale is never completely visible in the canvas, so when I do it online, I always have to manually shift that bar a bit to the left.
When I print it in a gif file, I cannot do this. How can I tell ROOT (or TCanvas) to make the canvas big enough so that the entire COLZ color index fits inside the image?
I have uploaded an example: Does “yellow” correspond to 110, 1100, or 11000? (As it turns out, it’s 11000).

Hi,
I always set the right margin of the canvas manually to “shift” the z-axis color bar. That is, if my canvas has the size as shown in this ctor:

TCanvas* myC = new TCanvas("myC", "Name of myC", 0, 0, 800, 600);

, it’s enough to do

myC->SetRightMargin(0.18);

right after to squash the histogram a bit, then the color bar will shift to the left. In case of a different canvas size I presume you should play with that 0.18 value a bit.

Hi,

That’s great. Yes, you’re right, that works perfectly.
Thanks,

Machiel

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