Tree: draw two histogramm in the same pad is different?

void two()
{
float x,y;
float nlines=0.0;
FILE *fp;
if((fp=fopen(“fit.txt”,“r”))==NULL)
{
printf("\n cannot open file! ! ! \n\n");
return;
}
TFile *file=new TFile(“two.root”,“RECREATE”);
TTree *tree=new TTree(“tree”,“data from ascii file”);
tree->Branch(“x”,&x,“x/F”);
tree->Branch(“y”,&y,“y/F”);
while(!feof(fp))
{
fscanf(fp,"%f %f",&x,&y);
if(feof(fp)) break;
tree->Fill();
nlines++;
}
printf(“found %f points \n”,nlines);
tree->Draw(“y”);
tree->Draw(“x”,"",“same”);
file->Write();
tree->Write();
fclose(fp);
}
i draw x and y histogramm in the same pad, why it is different from draw x only(or draw y only)?





different binning in your histograms.
Try this:

[code]
hx = new TH1F(“hx”, “hx”, 100, 2500, 3500);
hy = new TH1F(“hy”, “hy”, 100, 2500, 3500);

//tree->Draw(“y”); // ROOT create htemp histogram with “any” binning
tree->Draw(“y>>hy”);
tree->Draw(“x>>hx”,“”,“same”);

tree->Draw(“x>>hx”);[/code]see: root.cern.ch/root/htmldoc/TTree.html#TTree:Draw

Jan