Re: [ROOT] Histogram labels

From: Rene Brun (Rene.Brun@cern.ch)
Date: Tue Jan 08 2002 - 22:22:11 MET


Hi Alberto,

I have recently added support for alphanumeric labels.
There are also many new tutorials illustrating this
new facility.
See labels1.C, labels2.C, hlabels1.C, hlabels2.C, cernstaff.C
and hbars.C
The new code is in CVS.
Below, you will find the documentation that I have added
to TH1::Draw

Rene Brun

//     Alphanumeric Bin Labels
//     =======================
//     By default, an histogram axis is drawn with its numeric bin labels.
//     One can specify alphanumeric labels instead with:
//        1- call TAxis::SetBinLabel(bin,label);
//           This can always be done before or after filling.
//           When the histogram is drawn, bin labels will be automatically
drawn.
//           See example in $ROOTSYS/tutorials/labels1.C, labels2.C
//        2- call to a Fill function with one of the arguments being a
string, eg
//           hist1->Fill(somename,weigth);
//           hist2->Fill(x,somename,weight); 
//           hist2->Fill(somename,y,weight); 
//           hist2->Fill(somenamex,somenamey,weight); 
//           See example in $ROOTSYS/tutorials/hlabels1.C, hlabels2.C
//        3- via TTree::Draw.
//           see for example $ROOTSYS/tutorials/cern.C
//           tree.Draw("Nation::Division"); where "Nation" and "Division"
//           are two branches of a Tree.  
//     When using the options 2 or 3 above, the labels are automatically
//     added to the list (THashList) of labels for a given axis.
//     By default, an axis is drawn with the order of bins corresponding
//     to the filling sequence. It is possible to reorder the axis
//       - alphabetically
//       - by increasing or decreasing values
//     The reordering can be triggered via the TAxis contextMenu by
selecting
//     the menu item "LabelsOption" or by calling directly
//        TH1::LabelsOption(option,axis) where
//          -axis may be "X","Y" or "Z"
//          -option may be:
//           option = "a" sort by alphabetic order
//                  = ">" sort by decreasing values
//                  = "<" sort by increasing values
//                  = "h" draw labels horizonthal
//                  = "v" draw labels vertical
//                  = "u" draw labels up (end of label right adjusted)
//                  = "d" draw labels down (start of label left adjusted)
// 
//     When using the option 2 above, new labels are added by doubling the
current
//     number of bins in case one label does not exist yet. 
//     When the Filling is terminated, it is possible to trim the number
//     of bins to match the number of active labels by calling
//           TH1::LabelsDeflate(axis) with axis = "X","Y" or "Z"
//     This operation is automatic when using TTree::Draw.
//     Once bin labels have been created, they become persistent if the
histogram
//     is written to a file or when generating the C++ code via
SavePrimitive.


On Tue, 8 Jan 2002, Alberto Pulvirenti wrote:

> Dear all,
> 
> is there anybody who knows how to manage the TH1 labels?
> I'm sudying a HIJING event and I would examine the multiplicities of 
> some particle, so I would label each histogram bin with the name of the 
> corresponding particle. Is it possible?
> 
> Cheers,
> 
> Alberto
> 



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:37 MET