# How to remove one point from TGraph

**URL:** <https://root-forum.cern.ch/t/how-to-remove-one-point-from-tgraph/19697>\
**Category:** ROOT\
**Created:** [August 14, 2015, 1:43pm UTC](https://root-forum.cern.ch/t/how-to-remove-one-point-from-tgraph/19697 "2015-08-14T13:43:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![michael91](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/43a26b/32.png) [@michael91](https://root-forum.cern.ch/u/michael91)\
**Post date:** [August 14, 2015, 1:43pm UTC](https://root-forum.cern.ch/t/how-to-remove-one-point-from-tgraph/19697/1 "2015-08-14T13:43:56Z")

</div>

Hi all,

I am new root user. I got a task to create multigraph and put two graphs on one canvas. It is ok, there is however one problem I did not manage to solve although I have been looking through this forum.

I need to remove one point that is a garbage, how can I do it in my code?

//**_Declaring fiiting function \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
Double\_t fitfunction(Double\_t x, Double\_t par)  
{  
return par[0]+par[1]/pow(x[0],par[2])+par[3]/pow(x[0],pow(2,par[4]));  
}  
//_**\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
int new\_fit()  
{  
TFile \*f = new TFile(“PlotList\_GE11\_IV\_Gas\_Comparison\_R10\_21\_AND\_R340\_352\_unswapped.root”);  
f-\>cd(“Comp\_GE11\_IV\_Gas\_Comparison/timeResp/10\_21”);

```
TGraphErrors *gr1 = (TGraphErrors*)gDirectory->Get("graph_Comp_GE11_IV_Gas_Comparison_10_21");
f->cd("Comp_GE11_IV_Gas_Comparison/timeResp/340_352");

TGraphErrors *gr2 = (TGraphErrors*)gDirectory->Get("graph_Comp_GE11_IV_Gas_Comparison_340_352");

//Creating canvas
TCanvas *c1 = new TCanvas("c1","Fitted points",800,600);

c1->SetGridx();
c1->SetGridy();

//Creating multigraph
TMultiGraph *mg = new TMultiGraph();
//mg->SetTitle("Time response vs. gain");

gr1->SetMarkerColor(2);
gr1->SetMarkerStyle(22);
gr1->SetMinimum(0);
gr1->SetMaximum(30);

gr2->SetMarkerColor(4);
gr2->SetMarkerStyle(25);
gr2->SetMinimum(0);
gr2->SetMaximum(30);

mg->Add(gr1);
//mg->Add(gr2);
mg->Draw("AP");

```

}

The problem is in one of two graphs. One point has got really big uncertainities and is far far away from others. I should treat it as a garbage.  
So what I can do is either:

1. remove this point - how?

2. set Y axis range of plotting. - how?

Other task id to fit these points but this is something I have been doing before, so I will manage to do it.  
Thank you very much for any responses.

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [August 14, 2015, 2:00pm UTC](https://root-forum.cern.ch/t/how-to-remove-one-point-from-tgraph/19697/2 "2015-08-14T14:00:14Z")

</div>

Delete point number “ipoint”: [TGraph::RemovePoint (Int\_t ipoint)](https://root.cern.ch/root/html/TGraph.html#TGraph:RemovePoint@1)  
Delete point close to the mouse position: [TGraph::RemovePoint ()](https://root.cern.ch/root/html/TGraph.html#TGraph:RemovePoint)

How to set / adjust axis range in canvas: [How to adjust range in canvas?](https://root-forum.cern.ch/t/how-to-adjust-range-in-canvas/18048/5)

---

<div class="post-metadata">

**Author:** ![michael91](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/43a26b/32.png) [@michael91](https://root-forum.cern.ch/u/michael91)\
**Post date:** [August 17, 2015, 9:19am UTC](https://root-forum.cern.ch/t/how-to-remove-one-point-from-tgraph/19697/3 "2015-08-17T09:19:18Z")

</div>

Thank you very much!  
I will try to implement it.
