Pallete does not follow right margin

Hi!

I start a new thread although it’s a kind of follow up on [url]Unable to set pad to logarithmic scale using THStack pads

I would like to move the palette according to the right margin I set. Usually the pallete follows the right margin. But not in my case.


I’m probably missing again the right spot to call for Update.

margin() {

    TH2F* h1 = new TH2F("h1","h1",100,-5,5, 100, -5, 5);
    h1->FillRandom("gaus");

    TH2F* h2 = new TH2F("h2","h2",100,-5,5, 100, -5, 5);
    h2->FillRandom("gaus");

    THStack* stack = new THStack("hstack","hstack");
    stack->Add(h1,"colz");
    stack->Add(h2,"colz");

    gStyle->SetOptStat(0);

    c2 = new TCanvas("c2","c2");
    stack->Draw("pads");
    gPad->Update();

    c2->cd(1);
    gPad->SetRightMargin(0.5); // disabled for margin1.png, enabled for margin2.png
    gPad->SetLogz(1);

}

I know that if I access the pallete directly I can set its NDC (movepal.C example). I would not like to do it because at the end I will use THStack from TH2 or TH3 (projections) so I don’t have the histogram pointers at hand.

Thanks in advance,

Sebastian

PS: ROOT 5.30.00


One the plot is done the palette position ans the margin evolves separately. They are plot relatively to each other only at the Drawing time. For instance you can change the global setting with:

gStyle->SetPadRightMargin(0.5)

… and the palette will follow. But this will change all the right margins.
Another way would be to define a pad with the right margin you want and plot the histogram in it.
But the way you plot the histograms using THStack does not allow to do this because the pad are created at plotting time and you have no control on it.
By the way I do not really understand why you need a THStack in this case. You surely have good reasons.