Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
hist015_TH1_read_and_draw.py File Reference

Detailed Description

View in nbviewer Open in SWAN
A Simple histogram drawing example

import ROOT
from ROOT import TCanvas, TPad, TFile, TPaveLabel, TPaveText
from ROOT import gROOT
c1 = TCanvas( 'c1', 'Histogram Drawing Options', 200, 10, 700, 900 )
pad1 = TPad( 'pad1', 'The pad with the function', 0.03, 0.62, 0.50, 0.92, 21 )
pad2 = TPad( 'pad2', 'The pad with the histogram', 0.51, 0.62, 0.98, 0.92, 21 )
pad3 = TPad( 'pad3', 'The pad with the histogram', 0.03, 0.02, 0.97, 0.57, 21 )
#
# We connect the ROOT file generated in a previous tutorial
#
File = "py-hsimple.root"
ROOT.Info("hist015_TH1_read_and_draw.py", File+" does not exist")
exit()
example = TFile(File)
# Draw a global picture title
title = TPaveLabel( 0.1, 0.94, 0.9, 0.98,
'Drawing options for one dimensional histograms' )
#
# Draw histogram hpx in first pad with the default option.
hpx = gROOT.FindObject( 'hpx' )
label1 = TPaveLabel( -3.5, 700, -1, 800, 'Default option' )
#
# Draw hpx as a lego. Clicking on the lego area will show
# a "transparent cube" to guide you rotating the lego in real time.
hpx.DrawCopy( 'lego1' )
label2 = TPaveLabel( -0.72, 0.74, -0.22, 0.88, 'option Lego1' )
label2a = TPaveLabel( -0.93, -1.08, 0.25, -0.92, 'Click on lego to rotate' )
#
# Draw hpx with its errors and a marker.
hpx.Draw( 'e1p' )
label3 = TPaveLabel( 2, 600, 3.5, 650, 'option e1p' )
#
# The following illustrates how to add comments using a PaveText.
# Attributes of text/lines/boxes added to a PaveText can be modified.
# The AddText function returns a pointer to the added object.
pave = TPaveText( -3.78, 500, -1.2, 750 )
t1 = pave.AddText( 'You can move' )
pave.AddText( 'Title and Stats pads' )
pave.AddText( 'X and Y axis' )
pave.AddText( 'You can modify bin contents' )
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t SetFillColor
The Canvas class.
Definition TCanvas.h:23
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
Definition TFile.h:131
The most important graphics class in the ROOT system.
Definition TPad.h:28
A Pave (see TPave) with a text centered in the Pave.
Definition TPaveLabel.h:20
A Pave (see TPave) with text, lines or/and boxes inside.
Definition TPaveText.h:21
Author
Wim Lavrijsen

Definition in file hist015_TH1_read_and_draw.py.