setting axis titles

From: Selim Issever (selim.issever@desy.de)
Date: Thu Jan 06 2000 - 05:06:07 MET


Dear all,

I seem to make something really stupid. I want to set the x- and y-axis title
of the most recent drawn histogram automatically; so I dont know the explicit
histogram name. This is my approach:

===== a macro ========================================
{
  if (gPad) {
    TList   *list = gPad->GetListOfPrimitives();
    TObject *obj  = list->First();
  
    while(obj) {
      int cmpval = strncmp("TH", obj->ClassName(), 2);
      if( !cmpval ) {
	TH1 *hey = (TH1 *) obj;
	hey->SetXTitle("aaa");
	hey->SetYTitle("bbb");
      }
      obj = list->After(obj);
    }
  }
}
===== end a macro ====================================

for some odd reasons the macro implementation works, but as soon as I copy the
above snippet into a function and compile it with my root application it
doesnt work:

in my linkdef I've added the line:
#pragma link C++ function afunc;

===== afunc ==========================================
void afunc() {
  if (gPad) {
    TList   *list = gPad->GetListOfPrimitives();
    TObject *obj  = list->First();
  
    while(obj) {
      int cmpval = strncmp("TH", obj->ClassName(), 2);
      if( !cmpval ) {
	TH1 *hey = (TH1 *) obj;
	hey->SetXTitle("aaaaa");
	hey->SetYTitle("bbbbb");
      }
      obj = list->After(obj);
    }
  }
}
=============================================================

at the x axis nothing is displayed, at the y axis the string "aaaaa" is
displayed,.. 
I seem to miss something,.. does anybody know, where the problem is?

Thanks for your time!
Cheers,
Selim

-- 
Selim Issever | Tel: 040 8998-2843    +- "Unser Oertchen ist viel ----
DESY-F15      | Fax: 040 8998-4033    +- aelter als euer Scheiss-Marl.
Notkestr. 85  | selim.issever@desy.de +-------  Diplomand ------------
22603 Hamburg/Germany   |  http://www.physik.uni-dortmund.de/~issevers
<< S M M + +: Your new mapping mud client @ http://smm.mudcenter.com >>



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:16 MET