I’d like to draw a graph and its partly magnified image on a sub pad using TGraph::DrawClone().
Following commands work fine in interactive model, but when I try to automize this process by a macro, nothing is drawn on the sub pad.
Hello Satoru,
your problem is problem with gROOT->GetSelectedPad() (see in TObject::DrawClone). For example use graph.C from tutorials and modified your macro.C:
It sure works with gPad->Update().
It’s never occured to me because I thought that gPad->Update() is not about changing the status of objects but only about painting. It looks like a kind of pitfall …
By the way, the batch mode has another limitation: failure to interpret a one-liner cast such as
((TGraph*)p1.FindObject(“gr”))->GetYaxis()->SetNdivisions(505);
[quote]By the way, the batch mode has another limitation: failure to interpret a one-liner cast such as
((TGraph*)p1.FindObject(“gr”))->GetYaxis()->SetNdivisions(505); [/quote]
name of TGraph object is Graph !
[quote]root [16] p1.GetListOfPrimitives()->ls()
TFrame X1= 0.292600 Y1=1.185789 X2=0.606100 Y2=10.796640
OBJ: TGraph Graph a simple graph : 0 at: 0x9d63f88
OBJ: TPaveText title X1= 0.257331 Y1=11.123450 X2=0.343994 Y2=11.937929[/quote]
so:
((TGraph*)p1.FindObject("Graph"))->GetYaxis()->SetNdivisions(505)
or more clear:
clone->SetName("clone_gr");
((TGraph*)p1.FindObject("clone_gr"))->GetYaxis()->SetNdivisions(505);
Jan