# Redundant argument in TGraphPolar?

**URL:** <https://root-forum.cern.ch/t/redundant-argument-in-tgraphpolar/40368>\
**Category:** Newbie\
**Created:** [July 11, 2020, 11:10am UTC](https://root-forum.cern.ch/t/redundant-argument-in-tgraphpolar/40368 "2020-07-11T11:10:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![leungwingfung](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/ecd19e/32.png) [@leungwingfung](https://root-forum.cern.ch/u/leungwingfung)\
**Post date:** [July 11, 2020, 11:10am UTC](https://root-forum.cern.ch/t/redundant-argument-in-tgraphpolar/40368/1 "2020-07-11T11:10:11Z")

</div>

Hi everyone,

I have been learning ROOT following [this guide](https://root.cern.ch/root/htmldoc/guides/primer/ROOTPrimerLetter.pdf) and am confused with one of the arguments used in TGraphPolar in _Chapter 4.2 Polar Graphs_. The example code in the guide is

```auto
1 // Builds a polar graph in a square Canvas. 
2
3 void macro3(){
4 auto c = new TCanvas("myCanvas","myCanvas",600,600);
5 Double_t rmin=0.;
6 Double_t rmax=TMath::Pi()*6.;
7 const Int_t npoints=1000;
8 Double_t r[npoints];
9 Double_t theta[npoints];
10 for (Int_t ipt = 0; ipt < npoints; ipt++) {
11 r[ipt] = ipt*(rmax-rmin)/npoints+rmin;
12 theta[ipt] = TMath::Sin(r[ipt]);
13 }
14 TGraphPolar grP1 (npoints,r,theta);
15 grP1.SetTitle("A Fan");
16 grP1.SetLineWidth(3);
17 grP1.SetLineColor(2);
18 grP1.DrawClone("L");
19 }

```

The example code produces a graph of a fan with 3 flaps. What I am confused about is firstly the use of the variables. In the [documentation](https://root.cern.ch/doc/master/classTGraphPolar.html#a8c1707e002f589388075048f69699541) the theta variable comes before the r variable, but in this example, the r and theta are interchanged. I assume this is just an issue with naming variables since r ∈ [0,6π) and it seems like it is meant to be a variable in radians.

The second issue is that the angle argument (r in the example) seems to be redundant. I have seen a similar issue in [this post](https://root-forum.cern.ch/t/problem-in-tgraphpolar/19582) where the person asking the question changed the range to [0,π) and the graph still spans [0,2π). It seems that no matter what you put as the second argument the function still plots data points equally across the range [0,2π). Following the logic, the code should produce 3 overlapping sine curves wrapped around the origin. What should be the correct usage of TGraphPolar such that the angular argument is correctly implemented?

Thank you in advance. 🙂

_ROOT Version:_ 6.22.00

* * *

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [July 11, 2020, 1:17pm UTC](https://root-forum.cern.ch/t/redundant-argument-in-tgraphpolar/40368/2 "2020-07-11T13:17:32Z")

</div>

I’ll let @couet react on this once he’s back from vacation

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [July 22, 2020, 11:22am UTC](https://root-forum.cern.ch/t/redundant-argument-in-tgraphpolar/40368/3 "2020-07-22T11:22:21Z")

</div>

Thanks for you input.

The primer is now here: [https://root.cern/primer/](https://root.cern/primer/)

This PR update the example `macro3.C`

> <https://github.com/root-project/web/pull/341>
