Problem with TGraph from TTree::Draw with colour

Hi,

I am running root 5.20/00 on macosx.

I create a TGraph from a TTree using

tree->Draw("y:x:colour","","col")

which produces a scatter plot with coloured points. If I use the canvas menu (File -> Save As) to save the canvas as a .C macro, then the macro doesn’t include enough info to reproduce the plot. Specifically the following line appears in the macro.

//Primitive: graphs/An array of objects. You must implement TObjArray::SavePrimitive

The following code doesn’t change the marker as expected.

TGraph *graph = (TGraph*)gPad->GetPrimitive("Graph"); graph->SetMarkerStyle(20); graph->SetMarkerSize(1);

Regards,
Mark

To change the attributes you should start from the Tree/Ntuple itself:

root [1] ntuple->SetMarkerStyle(20);  
root [2] ntuple->Draw("px:py:pz","","col");

Hi Olivier,

Thank you, this helps.

Still, without explicit access to the TGraph object it’s unclear to me how work with it. For example, I would like to change the title that I get with such a plot.

Thanks,
Mark

ntuple.Draw("px:py");
htemp.SetTitle("new title")