# TGraph2D No Output

**URL:** <https://root-forum.cern.ch/t/tgraph2d-no-output/51137>\
**Category:** Newbie\
**Created:** [August 10, 2022, 12:45pm UTC](https://root-forum.cern.ch/t/tgraph2d-no-output/51137 "2022-08-10T12:45:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheScientist](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/t/82dd89/32.png) [@TheScientist](https://root-forum.cern.ch/u/TheScientist)\
**Post date:** [August 10, 2022, 12:45pm UTC](https://root-forum.cern.ch/t/tgraph2d-no-output/51137/1 "2022-08-10T12:45:48Z")

</div>

I am trying to create 2D graph as shown below.

 ![image](https://root-forum.cern.ch/uploads/default/original/3X/f/a/fa353f6f51a2c2c9792d105db0e168bb3c2217c1.jpeg)  
 ![image](https://root-forum.cern.ch/uploads/default/original/3X/4/7/4784c98acd8fc86046f0542b0fb661b703b51fc9.png)

My code:

```auto
n = 82560
g = ROOT.TGraph2D()

for x in range(128):
    for y in range(645):
        for z in adc13[x]:
            g.SetPoint(n,x,y,z)

c1 = ROOT.TCanvas("c1")

g.Draw("TRI2 Z")
ROOT.gPad.Update()
g.GetXaxis().SetTitle("X-axis")
g.GetYaxis().SetTitle("Y-axis")
g.GetZaxis().SetTitle("Z-axis")
  
c1.SetTheta(0.0-0.001)
c1.SetPhi(0.0+0.001)
ROOT.gStyle.SetHistTopMargin(0)

c1.Print("TGraph2D_example1.png")

```

This code does not give me any output.

To be more precise.  
X = [0,1,2, …, 127] (128 elements)  
Y = [0,1,2,…, 644] (645 elements)  
Z = [different values] (128 x 645) = 82560 elements.

I am trying to plot like these:  
(x,y,z)  
(0,0,Z[0])  
(0,1,Z[1])  
(0,2,Z[2])  
…  
…  
(0,644,Z[127])  
(1,0, Z[128])  
(1,1,Z[129])  
…  
…  
Last two  
(127, 643, Z[82449])  
(127, 644, Z[82450])

I could not figure out what’s wrong in my code. It is not producing any plots. Thank you.

---

<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:** [August 10, 2022, 1:33pm UTC](https://root-forum.cern.ch/t/tgraph2d-no-output/51137/2 "2022-08-10T13:33:06Z")

</div>

what do you get with:

```auto
g.Draw("p0")

```

---

<div class="post-metadata">

**Author:** ![dastudillo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dastudillo/32/17280_2.png) [@dastudillo](https://root-forum.cern.ch/u/dastudillo)\
**Post date:** [August 10, 2022, 2:16pm UTC](https://root-forum.cern.ch/t/tgraph2d-no-output/51137/3 "2022-08-10T14:16:45Z")

</div>

Read the [documentation](https://root.cern/doc/master/classTGraph2D.html#G2D00) on the parameters for SetPoint. Don’t use “n” in your case.

---

<div class="post-metadata">

**Author:** ![TheScientist](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/t/82dd89/32.png) [@TheScientist](https://root-forum.cern.ch/u/TheScientist)\
**Post date:** [August 10, 2022, 2:36pm UTC](https://root-forum.cern.ch/t/tgraph2d-no-output/51137/4 "2022-08-10T14:36:15Z")

</div>

Yep. I was using ‘n’ as in TGraph 1D. Once I figured it out for 2D, it worked out. Thank you.
