Plot graph but an excess graph appear

Hi all experts,
I plot graphs via root as following code. I only wanna graph “gr1” appear in the diagram, but it arises two graphs in the diagram drawn as the picture below. One comes from “gr0” and the other comes from “gr3”. How can I change the code to make “gr3” doesn’t apper in the diagram without removind the code of “gr3” since it will be used in later code. I alse upload the original data file in case you need. please first change the postfix to “.csv” when you use the data, beause here can’t upload “.csv” file.
thank you
Best regards,

void plot_mtt_cut(){
	TTree *t = new TTree("t", "tree from mtt_yt.csv");
	t->ReadFile("mtt_yt.csv", "yt0_X/D:yt0_Y:yt1_X:yt1_Y:yt2_X:yt2_Y");
	t->Draw("yt0_Y:yt0_X");
	TGraph *gr0=(TGraph*) gROOT->FindObject("Graph")->Clone();
	t->Draw("yt1_Y:yt1_X");
	TGraph *gr1=(TGraph*) gROOT->FindObject("Graph")->Clone();
	t->Draw("yt2_Y:yt2_X");
	TGraph *gr2=(TGraph*) gROOT->FindObject("Graph")->Clone();
	TTree *t3=new TTree("t3","tree from mtt_yt3.csv");
	t3->ReadFile("mtt_yt3.csv","yt3_X/D:yt3_Y");
	t3->Draw("yt3_Y:yt3_X");
	TGraph *gr3=(TGraph*) gROOT->FindObject("Graph")->Clone();

	gr0->Sort();
	gr1->Sort();
	gr2->Sort();
	gr3->Sort();
	gr1->Draw("CP");
}


mtt_yt.txt (2.3 KB) mtt_yt3.txt (422 Bytes)

  gr1->Draw("ACP");
1 Like

Thank you. it works, but why does it work?
I know the parameter means : “ A ” Axis are drawn around the graph.
why does it solve the problem? thank you.
Best wishes.

https://root.cern.ch/doc/master/TGraph_8cxx_source.html#l00751
in your case, line 780 applies when you add “A”.

I got it . thank you.

Please read the “Tips for Efficient and Successful Posting” and the “Posting code? Read this first!”.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.