TAxis in TMultiGraphs a null pointer

Hi,

when running this function, mg->GetXaxis() and mg1->GetXaxis() are null pointers, although mg2->GetXaxis() is not. However, if I add the lines commented out,
"cout << mg->GetXaxis() << " " << mg->GetYaxis() << endl;"
all TAxis() are constructed.

Is this the wanted behaviour?
Regards
michele

I think my request wasn’t clear at all. Apologies.
When I run this function plot(), that creates three TCanvases, three TMultiGraphs and three TGraphs, the function GetXaxis() returns a non zero value only for the last constructed TMultiGraph. But if I uncomment the statement
cout << mg->GetXaxis() …
all TAxis seems constructed.
Is this the wanted behaviour?
Regards
michele

void plot()
{
TCanvas *can = new TCanvas(“can”, “”, 600, 400);
TCanvas *can1 = new TCanvas(“can1”, “”, 600, 400);
TCanvas *can2 = new TCanvas(“can2”, “”, 600, 400);

TMultiGraph *mg = new TMultiGraph();
TMultiGraph *mg1 = new TMultiGraph();
TMultiGraph *mg2 = new TMultiGraph();

TGraph *gr = new TGraph(1);
TGraph *gr1 = new TGraph(1);
TGraph *gr2 = new TGraph(1);

can->cd();
mg->Add(gr); mg->Draw(“apl”);
//cout << mg->GetXaxis() << " " << mg->GetYaxis() << endl;
can1->cd();
mg1->Add(gr); mg1->Draw(“apl”);
//cout << mg1->GetXaxis() << " " << mg1->GetYaxis() << endl;
can2->cd();
mg2->Add(gr); mg2->Draw(“apl”);
//cout << mg2->GetXaxis() << " " << mg2->GetYaxis() << endl;

cout << mg << " " << mg1 << " " << mg2 << endl;
cout << gr << " " << gr1 << " " << gr2 << endl;
cout << mg->GetXaxis() << " " << mg1->GetXaxis()
<< " " << mg2->GetXaxis() << endl;
cout << mg->GetYaxis() << " " << mg1->GetYaxis()
<< " " << mg2->GetYaxis() << endl;
return;
}

You must be using an old version

Rene

Hi Rene

on both 4.04/02 and 4.03/04 I observe the same behaviour. The machine is Debian and root has been compiled with threads and python bindings enabled.
Could you reproduce the problem?

Regards
michele

Sorry, I overlooked this problem.

The axis are created only when the graphs/multigraphs are painted.

You should add the following calls before your last couts

can->Update(); can1->Update(); can2->Update();

Your first couts work because you call them for the objects still
in the current pad. In this case, GetAxis is able to trigger the automatic
paint for the objects in the current pad.

Rene

Thanks
michele