Setting Color For Points Plotted In Scatter Plot

Hi,

I have a simple program to generate a scatter plot. I am able to change the background color of the plot but not sure how to change the color of the plotted points themselves.

My program is follows:

int main (int argc, char * argv[]) {
        
        TApplication theApp("App", &argc, argv);
//       TStyle *mystyle = new TStyle("MyStyle", "This is my style");
      gStyle->SetCanvasColor(9);

//      gROOT->SetStyle("MYstyle");
        TFile *f = new TFile ("50T.root");
        if (f->IsZombie()) {
                cout<<"Error opening file."<<endl;
                exit(-1);
        }
                
        TTree *bp50T=(TTree*) f->Get("Tcombine");
        
        bp50T->Print();
        
        bp50T->Show(50);
        
        //tree->Show(10);
        TCanvas *myCanvas=new TCanvas("c", "Px",400, 400);
        myCanvas->Connect("Closed()", "TApplication", &theApp, "Terminate()");
        
        bp50T->Draw("time:Px","", "",1000, 20000);
        myCanvas->Update();
        bp50T->StartViewer();
        
        theApp.Run();
        
    return 0;
}

What variable do I use to set the color of the plotted points?

Thank you.

Jon

You can set the marker color in 2 ways
1- set the Tree marker color, the generated graph will inherit the properties
from the Tree. Before calling bp50T-Draw, do, eg

bp50T-SetMarkerColor(kRed)
2a- abfter bp50T-Draw, do, eg

TGraph *g = (TGraph*)myCanvas->GetPrimitive("Graph"); g->SetMarkerColor(kRed); 2b- simply use the right mouse button clicking on the graph and select
SetMakerAttributes

Rene

[quote=“brun”]You can set the marker color in 2 ways
1- set the Tree marker color, the generated graph will inherit the properties
from the Tree. Before calling bp50T-Draw, do, eg

bp50T-SetMarkerColor(kRed)
2a- abfter bp50T-Draw, do, eg

TGraph *g = (TGraph*)myCanvas->GetPrimitive("Graph"); g->SetMarkerColor(kRed); 2b- simply use the right mouse button clicking on the graph and select
SetMakerAttributes

Rene[/quote]

Thank you very much!
I’ve got my answer here.:slight_smile: