{ gROOT->Reset(); gROOT->LoadMacro("Bernstein.C"); int n; cout << "Enter n: " << endl; cin >> n; TCanvas* c1 = new TCanvas("c1", "c1", 10, 10, 500, 500); c1->SetBottomMargin(0.15); c1->SetLeftMargin(0.15); stringstream ss; string str; ss << n; ss >> str; string outfile = "bernstein_" + str + ".eps"; TF1* f = new TF1("f", Bernstein, 0., 1., 2); f->SetMinimum(0.); f->SetMaximum(1.1); f->SetLineWidth(2.); for (int k=0; k<=n; k++){ double kd = static_cast(k); double nd = static_castSetParameter(0,kd); f->SetParameter(1,nd); if ( k == 0 ) { f->Draw(); // need this first to draw axes } f->DrawCopy("same"); // puts curve on the plot } f->GetXaxis()->SetLabelFont(42); // default = 62 f->GetYaxis()->SetLabelFont(42); f->GetXaxis()->SetTitleFont(42); f->GetYaxis()->SetTitleFont(42); f->GetXaxis()->SetLabelOffset(0.01); f->GetYaxis()->SetLabelOffset(0.015); f->GetXaxis()->SetLabelSize(.04); f->GetYaxis()->SetLabelSize(.04); f->GetXaxis()->SetNdivisions(8); // N2*100+N1 (N2=secondary, N1=primary) f->GetYaxis()->SetNdivisions(8); // N2*100+N1 (N2=secondary, N1=primary) f->GetXaxis()->SetTitleSize(0.05); // default = 0.04 (??? in manual, 0.02) f->GetYaxis()->SetTitleSize(0.05); f->GetXaxis()->SetTitleOffset(1.2); // factor multiplies default offset f->GetYaxis()->SetTitleOffset(1.2); title = "n = " + str; f->SetTitle(""); TLatex tl; tl->SetNDC(true); tl->SetTextFont(42); tl->DrawLatex(0.05, 0.95, title.c_str()); f->GetHistogram()->GetXaxis()->SetTitle("x"); f->GetHistogram()->GetYaxis()->SetTitle("b_{k,n}(x)"); f->GetXaxis()->SetTickLength(0.02); // default = 0.03 f->GetYaxis()->SetTickLength(0.02); // default = 0.03 c1->Modified(); c1->Print(outfile.c_str()); }