Multiple graphs in TGraph2D

Dear ROOTers

I’m trying to represent some kind of event display in a RTPC, showing only hits (points). I started with OGL representation but I founr it can not represent only points, just lines joining the events.

Then I went to TGraph2D, wit the option PCOL so I can see different positions of my events along Z.

What I would like is getting a set of points with one color (using P0 option) and then another set of points with different color and plot them in the same canvas. I tried to do an array of TGraph2D and use “P0 same” but:

  • the array doesn’t work
  • the option same doesn’t work here.

Any advice?

I could try to show the code after clean it a while.

Thank you

This one works for me.

void graph2dsame4()

   TCanvas *c = new TCanvas("c","Graph2D example",0,0,800,800);

   TH3F *frame3d = new TH3F("frame3d","frame3d",10,0,10,10,1,10,10,0,10);

   Double_t x1[4] = {1,1,2,2};
   Double_t y1[4] = {1,2,1,2};
   Double_t z1[4] = {1,2,3,4};
   TGraph2D *g2d1 = new TGraph2D(4,x1,y1,z1);
   g2d1->Draw("PCOL SAME");

   Double_t x2[4] = {5,5,7,7};
   Double_t y2[4] = {5,7,5,7};
   Double_t z2[4] = {5,7,3,8};
   TGraph2D *g2d2 = new TGraph2D(4,x2,y2,z2);

   g2d2->Draw("PCOL SAME");

Thank you for your answer.

So, fast question, it is possible something like

TGraph2D *g2d1[5] ;
  for(Int_t i=0; i<5; i++)
	g2d1[i] = new TGraph2D(nop_c,pos,trans_pos[i]);

an array of TGraphs2D? I know it is possible with TGraph, and with your answer it looks like it is possible to draw it. I’m answering before trying just to save time due to the time difference. Thank you very much.

I’m sorry for the double post.

Now it works, and with the array of TGrpahs2D

Thank you