Multiple Markers in a plot

Hello All,
I am trying to see if I can use multiple markers with a single plot. The reason is to identify visually points on a plot. Here is what I wrote:

TCanvas c1(“Detector Position”,“Detector Position”,0,0,600,600);

for (Int_t i=0;i<6;i++) {
DetectPos1->SetMarkerSize(3);
DetectPos1->SetMarkerStyle(20+i);
DetectPos1->SetMarkerColor(31+i);
DetectPos1->Draw();
}

The result has the same markers. How do I fix this? How does one draw different markers for different data points?

thank.

MT


You are using always the same pointer DetectPos1 to draw the markers. So the markers attributes will be the last ones you defined. What kind of object is DetectPos1 ? can you send a complete macro showing the problem ?
One simple answer (independant to the kind of object you are using) would be to have 5 “DetectPos” and draw them in the loop like:

for (Int_t i=0;i<6;i++) {
   DetectPos[i]->SetMarkerSize(3); 
   DetectPos[i]->SetMarkerStyle(20+i);
   DetectPos[i]->SetMarkerColor(31+i); 
   DetectPos[i]->Draw();
} 

thanks couet for the reply.

Here is a more complete macro:

TH2F *DetectPos1 = new TH2F(“DetectPos1”,“Transaxial detection position”,252,-500.,+500.,252,-500.,+500.);

for (Int_t i=0;i<6;i++) {
DetectPos1->SetMarkerSize(3);
DetectPos1->SetMarkerStyle(20+i);
DetectPos1->SetMarkerColor(31+i);
DetectPos1->Draw();
}

There are many ways of achieving what you want. One of them below

Rene

{
   TCanvas *c1 = new TCanvas("c1","c1",600,600);
   TH2F *DetectPos1 = new TH2F("DetectPos1","Transaxial detection position",252,-500.,+500.,252,-500.,+500.);
   DetectPos1->SetStats(0);
   DetectPos1->Draw();
   TRandom r;
   TMarker m;
   m.SetMarkerSize(3);
   Double_t x,y, R=400;
   for (Int_t i=0;i<6;i++) {
      m.SetMarkerStyle(20+i);
      m.SetMarkerColor(i+1);
      r.Circle(x,y,R);
      m.DrawMarker(x,y);
   }
}

I used the code you wrote with
m.DrawMarker(globalPosX1,globalPosY1);
and that worked wonderfully.

Thanks so much.