Re: Scatter Plot
Rene Brun (Rene.Brun@cern.ch)
Fri, 20 Nov 1998 02:14:50 +0100
Scott Sampson wrote:
>
> Hi,
>
> I want to superimpose a scatter plot on a frame and then draw a function
> on top, so I do the following:
>
> gPad->SetLogy();
> gPad->SetLogx();
>
> gPad->DrawFrame(0.01,400,1.0,90000);
> gPad->Update();
> h2da->Draw("Q2jbc:xjbc>>histo","Q2jbc>400 && yjbc<0.95","SAME");
> gPad->Update();
>
> TF1 *fun1 = new TF1("fun1","(300*300*x)",0.001,1);
> fun1->SetLineWidth(2);
> fun1->SetLineStyle(2);
> fun1->DrawCopy("SAME");
> gPad->Update();
>
> There are a few things I would like to change:
>
> 1) change the marker size and style
> 2) add labels to the x and y axes
> 3) superimpose another scatter plot on top with a different marker style
>
> How can I do these easily? I've tried a number of approaches, but none
> have worked fully. Thanks,
>
> Scott
Hi Scott,
I have modified your macro to do what you want.
Rene Brun
{
TCanvas *c1 = new TCanvas("c1");
gPad->SetLogy();
gPad->SetLogx();
// gPad->DrawFrame(0.01,400,1.0,90000);
TH2F *h2 = new TH2F("h2","",40,0.01,1,40,400,90000);
h2->Draw();
h2->GetXaxis()->SetTitle("X title");
h2->GetYaxis()->SetTitle("Y title");
gPad->Update();
h2da->SetMarkerStyle(20);
h2da->SetMarkerSize(0.4);
h2da->Draw("Q2jbc:xjbc>>histo","Q2jbc>400 && yjbc<0.95","SAME");
gPad->Update();
TF1 *fun1 = new TF1("fun1","(300*300*x)",0.001,1);
fun1->SetLineWidth(2);
fun1->SetLineStyle(2);
fun1->DrawCopy("SAME");
gPad->Update();
// change ntuple marker style/size again and draw again
}