Michal,
I have modified your code to show the two possibilities of annotation.
Some remarks:
- TH1::Draw erases the current pad by default. Everything drawn before
is erased.
- When you specify the axis titles, you can give blanks at the end
of the title strings. Blanks will be taken into account.
- When you want to draw a text at a fixed position on a picture,
independently of the picture range, you can set the Normalized Device
Coordinate (NDC) option in the text object.
- I have removed the part of your code reading your data file
(not available) and I am filling one bin only.
- The function below is directly executable.
Rene Brun
void Be()
{
Int_t NBINS = 173;
Int_t NLINES = 34;
char sline[80];
Int_t ii, jj;
TCanvas *c1 = new TCanvas("c1","Be Isotopes", 900, 700);
// Create Be histogram
Float_t xmin = 4.22;
Float_t xmax = xmin + (float) NBINS * 0.05;
Be_hist = new TH1F("Be_hist", "Be Isotopes", NBINS, xmin, xmax);
Be_hist -> Fill(6,10);
Be_hist -> SetXTitle("Calculated Mass ");
Be_hist -> SetYTitle("No. of Events per 0.05 Mass Units ");
Be_hist -> Draw();
TText *xlabel = new TText();
xlabel-> SetNDC();
xlabel -> SetTextFont(1);
xlabel -> SetTextColor(1);
xlabel -> SetTextSize(0.03);
xlabel -> SetTextAlign(22);
xlabel -> SetTextAngle(0);
xlabel -> DrawText(0.5, 0.04, "Calculated Mass");
TText *ylabel = new TText();
ylabel-> SetNDC();
ylabel -> SetTextFont(1);
ylabel -> SetTextColor(1);
ylabel -> SetTextSize(0.03);
ylabel -> SetTextAlign(22);
ylabel -> SetTextAngle(90);
ylabel -> DrawText(0.06, 0.5, "No. of Events per 0.05 Mass Unit");
title = new TPaveLabel(0.1, 0.94, 0.9, 0.98, "Be Isotopes");
title -> SetFillColor(16);
title -> Draw();
}