General appearance

Set background colour

To replace a grey background with white, use:

c1->SetFillColor(10);

where c1 is the canvas name. It's also possible to use kWhite rather than the value 10.

(Neil Collins, 25 September 2008)

Annotating plots

Draw line

This can be done in one line using the syntax:

(new TLine(-10, 0.4, 10, 0.4))->Draw();

The arguments of the TLine constructor are co-ordinates based on the histogram axes.

(Chris Curtis, 25 September 2008)

Draw arrow

To draw an arrow on a plot at a specific place, use the same technique as for Draw line, but use TArrow rather than TLine.

All you need to do if you want the arrow in the opposite direction is to reverse the co-ordinates.

(Neil Collins, 25 September 2008)

Add legend

To add a legend to the plot, you need to do something like the following:

// Create legend object and define legend size
// First two arguments are the bottom left corner position
// and the second two are the top right corner
leg = new TLegend(0.45,0.65,0.85,0.80);
// Add legend entries, giving: Histo name, label, option for marker type
// For the marker type, l draws a line, p matches to the points used in the plot
leg->AddEntry(Run1_TauRec_minimum_d_R_c2,"Z#rightarrow#tau#tau","l");
leg->AddEntry(Run2_TauRec_minimum_d_R_c2,"t#bar{t}","l");
// Option to set text size (and override legend size)
leg->SetTextSize(0.055);
// Set legend boarder type (usually defaults to being like the stats box)
leg->SetBorderSize(1);
// Set background colour as white
leg->SetFillColor(kWhite);
// Draw legend on plot
leg->Draw();

(Neil Collins, 25 September 2008)

Topic revision: r2 - 03 Oct 2008 - 12:50:47 - KarlHarrison
 
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback