TCanvas putting histogram row wise

Hello expert/root user
Is there a way to put histogram column wise in TCanvas.


Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


column-wise:

C->Divide(1,3);
C->cd(1); h1->Draw();
C->cd(2); h2->Draw();
C->cd(3); h3->Draw();

row-wise:

C->Divide(3,1);
....

C->Divide(4,4)
I want to transpose its element

 for (Int_t i = 0; i <30 ; i++) {

    h1->GetYaxis()->SetRangeUser(i, i + 1);
    TProfile *h2 = (TProfile *)h1->ProjectionX();

    sm = i / 30;
    cc->cd(cm * 5 + c);
    h2->Clear();
    h1->Clear();

    cn++;
    cout <<c;
    if (cn > 29) {
      cn = 0;
      c = 0;
     
    }
    cm++;
    if (cm > 5) {
      cm = 0;
      c++;
       cout<<endl;
    }
  }

Is there a simple transpose function in root instead of doing cc->cd(cm * 5 + c)

cc->cd(5 * (i % 6) + (i / 6) + 1); // assumes cc->Divide(5, 6);

{
  Int_t nx = 10, ny = 10;
  TCanvas *c = new TCanvas("c", "c");
  c->Divide(nx, ny);
  TText t; t.SetTextSize(0.3);
  for (Int_t i = 0; i < (nx * ny); i++) {
    c->cd(nx * (i % ny) + (i / ny) + 1);
    t.DrawText(0.5, 0.5, Form("%d", i));
  }
  c->cd(0);
}
1 Like