How to enable scroll bar for canvas?

Hello!

I do not understand how to enable scrollbar.

Root version is 5.34/36.
My system: Scientific Linux release 7.2 (Nitrogen).
My gcc: gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-4).

I create file and save canvas in tree

        ...
        TCanvas canv("c", "c", 0, 0, 190, 500);
        canv.SetCanvasSize(500, 2000);
        canv.Divide(2, 3);
        ...

I do not see scrollbar.
In descrition I found:

void TCanvas::SetCanvasSize ( UInt_t ww, UInt_t wh )

Do I have any problems with these 3 lines of code?

Thank you in advance.
Best regards, Vladislav.

Unset (GUI):
Options->Auto Resize Canvas
from the Canvas menu bar

Well, if I open canvas then “Auto resize Canvas” is enabled by default.
In this case my graphs are small, canvas width and height equal to width and height of available space on screen.
I do not see scrollbars.

If then I unset “Auto resize Canvas” from GUI menu, I see scrollbars, but my graphs are small.
I want to have scrollbars, because I want to have a lot of graph with good view (normal size, not small) on single canvas.

So, as I understand, I have to unset “Auto resize Canvas” from script, not from GUI.
But you answered https://root-forum.cern.ch/t/auto-resize-canvas-option-off-by-default/13709/1:

So, what is solution?

void canvasscrollbars () {
   TCanvas *c = new TCanvas("c","c");
   c->SetCanvasSize(2000, 2000);
   c->SetWindowSize(800, 800);
   TF1 *f = new TF1 ("f","x*sin(x)",-10,10);
   f->Draw();
}

Many thanks for your help.
Yes, this code works well.
But I have more difficult situation:

void canvasscrollbars_create ()
{
   //good view - no problems

    TCanvas *c = new TCanvas("c","c");
   c->Divide(2, 4);
   c->SetCanvasSize(1500, 1500);
   c->SetWindowSize(800, 800);
   TF1 *f = new TF1 ("f","x*sin(x)",-10,10);

   c->cd(1);
   f->Draw();

   c->cd(2);
   f->Draw();

   c->cd(3);
   f->Draw();

   c->cd(4);
   f->Draw();

   c->cd(5);
   f->Draw();

   c->cd(6);
   f->Draw();

   c->cd(7);
   f->Draw();

   c->cd(8);
   f->Draw();


   TTree tree("t1", "Parser tree");
   tree.Branch("canvas_tr", "TCanvas", &c);
   tree.Fill();


   TFile file("/home/darkside/Vlad_Programs/test.root", "RECREATE");
   tree.Write();
   file.Close();
}

void canvasscrollbars_process ()
{
    TObjArray Hlist(0);
    Hlist.SetOwner(kTRUE);

    TCanvas* canv = 0;

    TChain chain("t1");
    chain.Add("/home/darkside/Vlad_Programs/test.root");
    chain.SetBranchAddress("canvas_tr", &canv);

    for (int i = 0; i < chain.GetEntries(); ++i)
    {
        chain.GetEntry(i);

        if(true)//some cuts
        {
            Hlist.Add( canv->Clone() );
        }
    }

    TFile file("/home/darkside/Vlad_Programs/test_result.root", "RECREATE");
    Hlist.Write();
    file.Close();
}
root -l
.L canvas.cpp
canvasscrollbars_create()
canvasscrollbars_process()
TBrowser a;

In this case test_result.root contains graphs with small size.
What should I change?

I get this:

root [0] .L aaa.C
root [1] canvasscrollbars_create()
root [2] canvasscrollbars_process()
Error in <TChain::LoadTree>: Cannot find tree with name t1 in file test.root
root [3] TBrowser a;

Where is the problem ? what should I look at ?

If I launch canvasscrollbars_create() I will get canvas with scrollbar and graphs with normal size:


But if I launch

canvasscrollbars_create() 
canvasscrollbars_process()

and open test_result.root in TBrowser I see canvas with small graphs (set or unset “Auto resize Canvas” in GUI do not change this situation).
Screenshot from 2016-11-03 10-03-07.png

My problem:
normal size of graphs if I launch canvasscrollbars_create() and small size of graphs in test_result.root


The file test_result.root is empty

$ root test_result.root
   ----------------------------------------------------------------
  | Welcome to ROOT 6.09/01                    http://root.cern.ch |
  |                                   (c) 1995-2016, The ROOT Team |
  | Built for macosx64                                             |
  | From heads/master@v6-09-01-283-g7eebe98, Nov 03 2016, 10:31:50 |
  | Try '.help', '.demo', '.license', '.credits', '.quit'/'.q'     |
   ----------------------------------------------------------------

root [0] 
Attaching file test_result.root as _file0...
(TFile *) 0x7fa244e73ff0
root [1] _file0->ls()
TFile**		test_result.root	
 TFile*		test_result.root	
root [2] 

My code:

void canvasscrollbars_create ()
{
   //good view - no problems

    TCanvas *c = new TCanvas("c","c");
   c->Divide(2, 4);
   c->SetCanvasSize(1500, 1500);
   c->SetWindowSize(800, 800);
   TF1 *f = new TF1 ("f","x*sin(x)",-10,10);

   c->cd(1);
   f->Draw();

   c->cd(2);
   f->Draw();

   c->cd(3);
   f->Draw();

   c->cd(4);
   f->Draw();

   c->cd(5);
   f->Draw();

   c->cd(6);
   f->Draw();

   c->cd(7);
   f->Draw();

   c->cd(8);
   f->Draw();


   TTree tree("t1", "Parser tree");
   tree.Branch("canvas_tr", "TCanvas", &c);
   tree.Fill();


   TFile file("/home/darkside/Vlad_Programs/test.root", "RECREATE");
   tree.Write();
   file.Close();
}

void canvasscrollbars_process ()
{
    TObjArray Hlist(0);
    Hlist.SetOwner(kTRUE);

    TCanvas* canv = 0;

    TChain chain("t1");
    chain.Add("/home/darkside/Vlad_Programs/test.root");
    chain.SetBranchAddress("canvas_tr", &canv);

    for (int i = 0; i < chain.GetEntries(); ++i)
    {
        chain.GetEntry(i);

        if(true)//some cuts
        {
            Hlist.Add( canv->Clone() );
        }
    }

    TFile file("/home/darkside/Vlad_Programs/test_result.root", "RECREATE");
    Hlist.Write();
    file.Close();
}

My output:

root test_result.root
Couldn't find font "-adobe-helvetica-medium-r-*-*-10-*-*-*-*-*-iso8859-1",
trying "fixed". Please fix your system so helvetica can be found, 
this font typically is in the rpm (or pkg equivalent) package 
XFree86-[75,100]dpi-fonts or fonts-xorg-[75,100]dpi.
  *******************************************
  *                                         *
  *        W E L C O M E  to  R O O T       *
  *                                         *
  *   Version   5.34/36      5 April 2016   *
  *                                         *
  *  You are welcome to visit our Web site  *
  *          http://root.cern.ch            *
  *                                         *
  *******************************************

ROOT 5.34/36 (v5-34-36@v5-34-36, Apr 05 2016, 10:25:45 on linuxx8664gcc)

CINT/ROOT C/C++ Interpreter version 5.18.00, July 2, 2010
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0] 
Attaching file test_result.root as _file0...
root [1] 
root [1] 
root [1] _file0->ls()
TFile**		test_result.root	
 TFile*		test_result.root	
  KEY: TCanvas	c;1	c

Try this:

gROOT->SetBatch(kTRUE);

Ok with your new code I get the canvas in the root file.

I see that, when saved, the canvas lose its scroll bars. I do not know why.

I see the same effect with my small example.

void canvasscrollbars () {
   TCanvas *c = new TCanvas("c","c");
   c->SetCanvasSize(2000, 2000);
   c->SetWindowSize(800, 800);
   TF1 *f = new TF1 ("f","x*sin(x)",-10,10);
   f->Draw();
}
Processing canvasscrollbars.C...
root [1] c->SaveAs("canvasscrollbars.root")
Info in <TCanvas::SaveAs>: ROOT file canvasscrollbars.root has been created

$  root canvasscrollbars.root
etc ...

So, do you know any solution?
How to enable scrollbars and have graphs with normal size?

not solution right now. I have to check.

Hello!

Any news about this problem?

Best regards, Vladislav.

No…

Hello!

Any news about this problem?
Should I post this in Jira?

Best regards, Vladislav.

yes you can.