Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
gr014_polar3.py
Go to the documentation of this file.
1## \file
2## \ingroup tutorial_graphs
3## \notebook
4## \preview Create a polar graph using a TF1 and draw it with PI axis.
5## See the [TGraphPolar documentation](https://root.cern/doc/master/classTGraphPolar.html)
6##
7## Since TGraphPolar is a TGraphErrors, it is painted with
8## [TGraphPainter](https://root.cern/doc/master/classTGraphPainter.html) options.
9##
10## \macro_image
11## \macro_code
12## \author Olivier Couet, Jamie Gooding
13
14import math
15
16import numpy as np
17import ROOT
18
19CPol = ROOT.TCanvas("CPol", "TGraphPolar Examples", 500, 500)
20
21rmin = 0
22rmax = math.pi * 2
23r = np.array([])
24theta = np.array([])
25
26fp1 = ROOT.TF1("fplot", "cos(x)", rmin, rmax)
27for ipt in range(1000):
28 r = np.append(r, ipt * (rmax - rmin) / 1000 + rmin)
29 theta = np.append(theta, fp1.Eval(r[ipt]))
30
31grP1 = ROOT.TGraphPolar(1000, r, theta)
34grP1.Draw("AOL")
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.