本文整理汇总了C++中TPaveStats::SetLineWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ TPaveStats::SetLineWidth方法的具体用法?C++ TPaveStats::SetLineWidth怎么用?C++ TPaveStats::SetLineWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TPaveStats
的用法示例。
在下文中一共展示了TPaveStats::SetLineWidth方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MakeNiceStatBox
void MakeNiceStatBox(TH1* histo){
TObject *statObj;
TPaveStats *stats;
statObj = histo->GetListOfFunctions()->FindObject("stats");
stats= static_cast<TPaveStats*>(statObj);
stats->SetFillColor(10);
stats->SetLineWidth(1);
stats->SetShadowColor(0);
stats->SetTextFont(42);
stats->SetTextSize(0.05);
//stats->SetLineColor(LineColors);
//stats->SetTextColor(LineColors);
stats->SetX1NDC(0.615);
stats->SetY1NDC(0.747);
stats->SetX2NDC(0.979);
stats->SetY2NDC(0.986);
}
示例2: DrawAllHistos
void DrawAllHistos(TString filename,Bool_t isMC,TString format){
// setTDRStyle("logredblue");
std::vector<TH1F*> h1vec;
std::vector<TH2F*> h2vec;
h1vec.clear();
h2vec.clear();
TFile *file = TFile::Open(filename);
// to get the names of the conditions
TObjArray *conditions_from_name = filename.Tokenize("_");
TString sa = conditions_from_name->At(1)->GetName();
TString sb = conditions_from_name->At(3)->GetName();
sb.ReplaceAll(".root","");
file->cd();
TDirectory *stardir = gDirectory;
TObject *thesourcedir;
TIter nextdir(stardir->GetListOfKeys());
while((thesourcedir=nextdir())){
TString dirName = thesourcedir->GetName();
stardir->cd(dirName);
TDirectory *current_sourcedir = gDirectory;
TH1::AddDirectory(kFALSE);
std::cout << "*************************" <<std::endl;
std::cout << "Reading Directory: " << dirName <<std::endl;
TObject *obj;
TIter next(current_sourcedir->GetListOfKeys());
while ((obj=next())) {
TString objName =obj->GetName();
if(objName.Contains("pfx")) continue;
if (objName.Contains("h2") && !objName.Contains("pfx")) {
//std::cout << "Reading: " << obj->GetName() <<std::endl;
TH2F* h2 = (TH2F*)file->Get(dirName+"/"+objName);
h2->SetName(objName+dirName);
h2vec.push_back(h2);
TCanvas *c = new TCanvas(h2->GetName(),h2->GetName(),800,600);
c->cd();
gPad->SetTopMargin(0.08);
gPad->SetRightMargin(0.15);
h2->SetStats(kFALSE);
h2->Draw("colz");
c->Draw();
c->cd();
TProfile *hpfx_tmp = (TProfile*) h2->ProfileX("_pfx",1,-1,"o");
hpfx_tmp->SetStats(kFALSE);
//hpfx_tmp->SetMarkerColor(kBlack);
hpfx_tmp->SetMarkerColor(kRed);
hpfx_tmp->SetMarkerSize(1.2);
hpfx_tmp->SetMarkerStyle(20);
hpfx_tmp->Draw("psame");
c->Draw();
cmsPrel(60.,sa,sb, isMC);
TString canvName = h2->GetName();
c->cd()->SetLogz();
c->SaveAs(canvName+"."+format);
} else {
TH1F* h1 = (TH1F*)file->Get(dirName+"/"+objName);
h1->SetName(objName+dirName);
h1vec.push_back(h1);
TCanvas *c = new TCanvas(h1->GetName(),h1->GetName(),600,600);
c->cd()->SetLogy();
h1->SetMarkerColor(kBlack);
h1->SetMarkerStyle(20);
h1->SetLineWidth(1.5);
h1->SetFillColor(393);
//h1->SetFillStyle(3005);
h1->Draw("hist");
h1->Draw("e1same");
c->Draw();
TObject *statObj;
TPaveStats *stats;
statObj = h1->GetListOfFunctions()->FindObject("stats");
stats= static_cast<TPaveStats*>(statObj);
stats->SetFillColor(10);
//.........这里部分代码省略.........
示例3: hw1
int hw1(){
//define landau formula
TF1* myf = new TF1("mylandau",landauf,-3,10,3);
myf->SetParameters(1.0,2,1);
//get ready to initial hist
/*
const int num = 3;
string histvName[num] = {"ld_1e2","ld_1e3","ld_1e4"};
string histvTitle[num] = {"Landau 100 entris","Landau 1000 entris","Landau 10000 entris"};
int histEntries[num] = {100,1000,10000};
//new hist and fill them
TCanvas* canvas = new TCanvas("myc","HW1",800,600);
TMultiGraph* mg = new TMultiGraph();
for(int i = 0;i<num;i++){
TH1F* tmp=new TH1F(histvName[i].c_str(),histvTitle[i].c_str(),100,-3,10);
tmp->FillRandom("mylandau",histEntries[i]);
}
gDirectory->Get(histvName[2])->Draw("e");
gDirectory->Get(histvName[1])->Draw("esame");
gDirectory->Get(histvName[0])->Draw("esame");
*/
TCanvas* canvas = new TCanvas("myc","HW1",800,600);
TH1F* h1 = new TH1F("h1","Landau 100 entries",15,-3,10);
TH1F* h2 = new TH1F("h2","Landau 1000 entries",60,-3,10);
TH1F* h3 = new TH1F("h3","Landau 10000 entries",200,-3,10);
h1->FillRandom("mylandau",100);
h2->FillRandom("mylandau",1000);
h3->FillRandom("mylandau",10000);
h3->GetXaxis()->SetTitle("x");
h3->GetXaxis()->CenterTitle(true);
h3->GetYaxis()->SetTitle("Entries");
h3->GetYaxis()->CenterTitle(true);
h3->SetStats(kFALSE);
TF1* fit3 = new TF1("fit3",landauf,-3,10,3);
fit3->SetParameters(1.0,2,1);
h3->SetMarkerColor(kRed);
h3->SetLineColor(kRed);
fit3->SetLineColor(kRed+2);
h3->Fit("fit3","q","e");
TF1* fit2 = new TF1("fit2",landauf,-3,10,3);
fit2->SetParameters(1.0,2,1);
h2->SetMarkerColor(kBlue);
h2->SetLineColor(kBlue);
fit2->SetLineColor(kBlue+2);
h2->Fit("fit2","q","esame");
TF1* fit1 = new TF1("fit1",landauf,-3,10,3);
fit1->SetParameters(1.0,2,1);
h1->SetMarkerColor(kGreen);
h1->SetLineColor(kGreen);
fit1->SetLineColor(kGreen+2);
h1->Fit("fit1","q","esame");
double h1M = h1->GetMean();
double h1R = h1->GetRMS();
double h1S = h1->GetSkewness();
double h2M = h2->GetMean();
double h2R = h2->GetRMS();
double h2S = h2->GetSkewness();
double h3M = h3->GetMean();
double h3R = h3->GetRMS();
double h3S = h3->GetSkewness();
cout<<setprecision(4);
cout<<"+----+--------+--------+--------+"<<endl;
cout<<"|hist| Mean | RMS |skewness|"<<endl;
cout<<"+----+--------+--------+--------+"<<endl;
cout<<"+ 1 |"<<setw(8)<<h1M<<"|"<<setw(8)<<h1R<<"|"<<setw(8)<<h1S<<"|"<<endl;
cout<<"+----+--------+--------+--------+"<<endl;
cout<<"+ 2 |"<<setw(8)<<h2M<<"|"<<setw(8)<<h2R<<"|"<<setw(8)<<h2S<<"|"<<endl;
cout<<"+----+--------+--------+--------+"<<endl;
cout<<"+ 3 |"<<setw(8)<<h3M<<"|"<<setw(8)<<h3R<<"|"<<setw(8)<<h3S<<"|"<<endl;
cout<<"+----+--------+--------+--------+"<<endl;
TPaveStats *ptstats = new TPaveStats(0.5747126,0.6334746,0.9353448,0.934322,"brNDC");
ptstats->SetName("stats");
ptstats->SetBorderSize(1);
ptstats->SetFillColor(0);
ptstats->SetLineWidth(2);
ptstats->SetTextAlign(12);
ptstats->SetTextFont(132);
ptstats->AddText(" hist Mean RMS skewness ");
ostringstream os;
cout<<setprecision(4);
os<<" 1 "<<setw(8)<<h1M<<" "<<setw(8)<<h1R<<" "<<setw(8)<<h1S<<" ";
ptstats->AddText(os.str().c_str());
os.str(string());
os<<" 2 "<<setw(8)<<h2M<<" "<<setw(8)<<h2R<<" "<<setw(8)<<h2S<<" ";
ptstats->AddText(os.str().c_str());
os.str(string());
os<<" 3 "<<setw(8)<<h3M<<" "<<setw(8)<<h3R<<" "<<setw(8)<<h3S<<" ";
ptstats->AddText(os.str().c_str());
ptstats->SetOptStat(0);
ptstats->SetOptFit(111);
//.........这里部分代码省略.........