# canvas

    //
    // To see the output of this macro, click  here
    // One of the first actions in a ROOT session is the creation of a Canvas.
    // Here we create a Canvas named "c1" with all default parameters
    //
    gROOT.Reset("c1");
    TCanvas c1("c1");
    //
    // Inside this canvas, we create two pads
    //
    TPad pad1("pad1","This is pad1",0.05,0.52,0.90,0.45);
    TPad pad2("pad2","This is pad2",0.05,0.02,0.90,0.45);
    pad1.SetFillColor(46);
    pad2.SetFillColor(46);
    pad1.Draw();
    pad2.Draw();
    //
    // A pad may contain other pads and graphics objects.
    // We set the current pad to pad2. Note that the current pad is always highlighted.
    //
    pad2.cd();
    TPad pad21("pad21","First subpad of pad2",0.02,0.05,0.46,0.90,17,3);
    TPad pad22("pad22","Second subpad of pad2",0.52,0.05,0.46,0.90,17,3);
    pad21.Draw();
    pad22.Draw();
    //
    // We enter some primitives in the created pads and set some attributes
    //
    pad1.cd();
    TText t1(0.5,0.8,"This is pad1");
    t1.SetTextAlign(22);
    t1.SetTextSize(0.2);
    t1.Draw();
    TLine line1(0.05,0.05,0.80,0.70);
    line1.SetLineWidth(8);
    line1.SetLineColor(2);
    line1.Draw();
    line1.DrawLine(0.6,0.1,0.9,0.9);
    TLine line2(0.05,0.70,0.50,0.10);
    line2.SetLineWidth(4);
    line2.SetLineColor(5);
    line2.Draw();
    //
    pad21.cd();
    TText t21(0.05,0.8,"This is pad21");
    t21.SetTextSize(0.1);
    t21.Draw();
    TPavesText paves(0.1,0.1,0.8,0.6);
    paves.AddText("This is a PavesText");
    paves.AddText("You can add new lines");
    paves.AddText("Text formatting is automatic");
    paves.SetFillColor(25);
    paves.Draw();
    pad22.cd();
    TText t22(0.05,0.8,"This is pad22");
    t22.SetTextSize(0.1);
    t22.Draw();
    TPaveLabel label(0.1,0.4,0.9,0.6,"This is a PaveLabel");
    label.SetFillColor(24);
    label.Draw();
    //
    // Try now to point on any object on the screen: pad, text, lines, etc.
    // When the cursor points to sensitive areas in an object, the cursor
    // shape changes and suggests the type of action that can be applied.
    //
    // For example, one can move, grow,shrink a pad.
    // A text can be moved.
    // A line can be moved or its end points can be modified.
    // One can move, grow and shrink PaveLabels and PavesText.
    // Try to change the canvas size.
    // In the canvas "File" menu, select the option "Print" to produce
    // a PostScript file with a copy of the canvas.

[ROOT page] [Class index] [Top of the page]

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.