Loosing axis title when saving TCanvas with THStack to file

Dear rooters,

I have a problem when saving a THStack to file. I am using ROOT version 5.18/00a.

I draw a THStack a first time in order to have access to the axis, then set its axis title and then print it again on a TCanvas. When I print the canvas on the screen or on a pdf file I see the titles on the axis.
If I save the canvas in a root file and then reopen it though, the titles are gone.
Furthermore, by inspecting the file manually, I see that the axisColor is set to 0 both for x and y axis.

One additional thing is that it seems to me that the default XaxisTitleColor for a THStack is 0, not black (1), so if one tries to write the title it is not displayed because transparent and one needs also to change the color. Is this a bug or a feature?

I add here a simple example macro showing the problems. It is a compiled macro. I use it by doing “.L testStack.C+” and then “testStack()”:

#include “TLegend.h”
#include “THStack.h”
#include “TFile.h”
#include “TCanvas.h”

void testStack() {

TFile * outputFile = new TFile(“stack.root”, “RECREATE”);
TCanvas * canvas = new TCanvas(“canvasName”, “canvasTitle”, 1000, 800);
THStack * stack = new THStack(“stackName”, “stackTitle”);

TH1F * histo = new TH1F(“name”, “title”, 100, 0, 100);


// Draw first to have access to the axis
// (as explained in THStack::GetXaxis() method)

// If this is not called the color will be 0 and you will not see the Xaxis title

// Tried all these but it still does not save the axis title to file
// canvas->Draw();
// canvas->Update();
// canvas->ForceUpdate();


Thank you in advance for any help,


I see the missing titles. I do not know yet what is going wrong. I’ll let you know.

Now fixed in the svn trunk. Thanks to have reported it.