当前位置: 首页>>代码示例>>C++>>正文


C++ TPaveStats::SetLineColor方法代码示例

本文整理汇总了C++中TPaveStats::SetLineColor方法的典型用法代码示例。如果您正苦于以下问题:C++ TPaveStats::SetLineColor方法的具体用法?C++ TPaveStats::SetLineColor怎么用?C++ TPaveStats::SetLineColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TPaveStats的用法示例。


在下文中一共展示了TPaveStats::SetLineColor方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ColourStatsBoxes

//________________________________________________________
void GFHistManager::ColourStatsBoxes(GFHistArray *hists) const
{
  // colours stats boxes like hists' line colors and moves the next to each other
  if (!hists) return;
  Double_t x1 = fStatsX1, x2 = fStatsX2, y1 = fStatsY1, y2 = fStatsY2;
  for (Int_t iH = 0; iH < hists->GetEntriesFast(); ++iH) {
    TH1 *h = hists->At(iH);
    if (!h) continue;
    TObject *statObj = h->GetListOfFunctions()->FindObject("stats");
    if (statObj && statObj->InheritsFrom(TPaveStats::Class())) {
      TPaveStats *stats = static_cast<TPaveStats*>(statObj);
      stats->SetLineColor(hists->At(iH)->GetLineColor());
      stats->SetTextColor(hists->At(iH)->GetLineColor());
      stats->SetX1NDC(x1);
      stats->SetX2NDC(x2);
      stats->SetY1NDC(y1);
      stats->SetY2NDC(y2);
      y2 = y1 - 0.005; // shift down 2
      y1 = y2 - (fStatsY2 - fStatsY1); // shift down 1
      if (y1 < 0.) {
	y1 = fStatsY1; y2 = fStatsY2; // restart y-positions
	x2 = x1 - 0.005; // shift left 2
	x1 = x2 - (fStatsX2 - fStatsX1); // shift left 1
	if (x1 < 0.) { // give up, start again:
	  x1 = fStatsX1, x2 = fStatsX2, y1 = fStatsY1, y2 = fStatsY2;
	}
      }
    } else if (gStyle->GetOptStat() != 0) { // failure in case changed in list via TExec....
      this->Warning("ColourStatsBoxes", "No stats found for %s", hists->At(iH)->GetName());
    }
  }
}
开发者ID:12345ieee,项目名称:cmg-cmssw,代码行数:33,代码来源:GFHistManager.C

示例2: plotSubDetResiduals

//------------------------------------------------------------------------------
void PlotAlignmentValidation::plotSubDetResiduals(bool plotNormHisto,unsigned int subDetId)
{
  setNiceStyle();
 
  gStyle->SetOptStat(11111);
  gStyle->SetOptFit(0000);

  TCanvas *c = new TCanvas("c", "c", 600,600);
  c->SetTopMargin(0.15);
  TString histoName= "";
  if (plotNormHisto) {histoName= "h_NormXprime";}
  else histoName= "h_Xprime_";
  switch (subDetId){
  case 1 : histoName+="TPBBarrel_0";break;
  case 2 : histoName+="TPEendcap_1";break;
  case 3 : histoName+="TPEendcap_2";break;
  case 4 : histoName+="TIBBarrel_0";break;
  case 5 : histoName+="TIDEndcap_1";break;
  case 6 : histoName+="TIDEndcap_2";break;
  case 7 : histoName+="TOBBarrel_3";break;
  case 8 : histoName+="TECEndcap_4";break;
  case 9 : histoName+="TECEndcap_5";break;
  }
  int tmpcounter = 0;
  TH1 *sumHisto = 0;
  for(std::vector<TkOfflineVariables*>::iterator it = sourceList.begin();
      it != sourceList.end(); ++it) {
    if (tmpcounter == 0 ) {
      TFile *f= (*it)->getFile();
      sumHisto =(TH1*) f->FindKeyAny(histoName)->ReadObj();//FindObjectAny(histoName.Data());
      sumHisto->SetLineColor(tmpcounter+1);
      sumHisto->SetLineStyle(tmpcounter+1);
      sumHisto->GetFunction("tmp")->SetBit(TF1::kNotDraw);
      sumHisto->Draw();
      
      //get statistic box coordinate to plot all boxes one below the other
      //gStyle->SetStatY(0.91);
      //gStyle->SetStatW(0.15);
      //gStyle->SetStatBorderSize(1);
      //gStyle->SetStatH(0.10);
      
      
      tmpcounter++;
    } else {
      sumHisto = (TH1*) (*it)->getFile()->FindObjectAny(histoName);
      sumHisto->SetLineColor(tmpcounter+1);
      sumHisto->SetLineStyle(tmpcounter+1);
      sumHisto->GetFunction("tmp")->SetBit(TF1::kNotDraw);
      //hstack->Add(sumHisto);
      
      c->Update();
      tmpcounter++;  
    }
    TObject *statObj = sumHisto->GetListOfFunctions()->FindObject("stats");
    if (statObj && statObj->InheritsFrom(TPaveStats::Class())) {
      TPaveStats *stats = static_cast<TPaveStats*>(statObj);
      stats->SetLineColor(tmpcounter+1);
      stats->SetTextColor(tmpcounter+1);
      stats->SetFillColor(10);
      stats->SetX1NDC(0.91-tmpcounter*0.1);
      stats->SetX2NDC(0.15);
      stats->SetY1NDC(1);
      stats->SetY2NDC(0.10);
      sumHisto->Draw("sames");
    }
  }
  //hstack->Draw("nostack");
  char PlotName[1000];
  sprintf( PlotName, "%s/%s.eps", outputDir.c_str(), histoName.Data() );
  
  c->Print(PlotName);
  //delete c;
  //c=0;
    
}
开发者ID:HeinerTholen,项目名称:cmssw,代码行数:76,代码来源:PlotAlignmentValidation.C

示例3: plot

// -----------------------------------------------------------------------------
// Create plots
void plot( std::string& path, 
	   std::string& type, 
	   std::string& sample, 
	   std::string& dir, 
	   std::string& histo,
	   double lumi,
	   bool scale ) {

  std::string canvas_name = histo + "_" + dir + "_" + type + "_" + sample;

  // Create canvas  
  TCanvas* canvas = new TCanvas(canvas_name.c_str(),"");
  canvas->SetFillColor(0);
  canvas->SetFrameBorderMode(0);
  canvas->SetFrameFillColor(0);
  canvas->SetTopMargin(0.10);
  canvas->SetBottomMargin(0.12);
  canvas->SetLeftMargin(0.12);
  canvas->SetRightMargin(0.15);

  // Retrieve histogram
  std::string file_name = path + type + "_" + sample + ".root";
  TFile* f =  new TFile(file_name.c_str(),"READ");
  TDirectory* d = (TDirectory*)f->Get(dir.c_str());
  TH2D* his = (TH1*)d->Get(histo.c_str());
  if ( !his ) return;

  //his->Rebin2D(2,2);

  if ( true ) { gPad->SetLogz(); }
  if ( scale ) his->Scale( lumi / 100. );
  his->SetMaximum(1.e4);
  his->SetMinimum(1.e-5);
  //his->SetMinimum( his->GetMinimum(1.e-12) );

//   his->SetMaximum( 20000. );
//   his->SetMinimum( 2.e-4 );

//   his->SetMaximum( 20000. );
//   his->SetMinimum( 20. );

  double xmin = his->GetXaxis()->GetXmin();
  double xmax = his->GetXaxis()->GetXmax();
  double ymin = his->GetYaxis()->GetXmin();
  double ymax = his->GetYaxis()->GetXmax();
  
  // Reset title
  std::string title = ";" + std::string(his->GetXaxis()->GetTitle()) + ";" + std::string(his->GetYaxis()->GetTitle());
  his->SetTitle(title.c_str());
  his->GetXaxis()->SetTitle("x_{2}");
  his->GetXaxis()->SetTitleOffset(1.2);
  his->GetYaxis()->SetTitle("x_{1}");
  his->GetYaxis()->SetTitleOffset(1.4);
  his->Draw("COLZ");
  gPad->Update();

  // Lumi
  if (1) { 
    std::stringstream ss;

    ss << "#int L dt = " << lumi << " pb^{-1}";
    double xpos = 0.05 * (xmax-xmin)+xmin;
    double ypos = 0.25 * (ymax-ymin)+ymin;
    TLatex* text1 = new TLatex(xpos,ypos,ss.str().c_str());
    text1->SetTextAlign(12); 
    text1->SetTextSize(0.035);
    text1->Draw();
  }

  // Jet type
  if (1) { 
    double xpos = 0.05 * (xmax-xmin)+xmin;
    double ypos = 0.15 * (ymax-ymin)+ymin;
    TText* text2 = new TText(xpos,ypos,type.c_str());
    text2->SetTextAlign(12); 
    text2->SetTextSize(0.035);
    text2->Draw();
  }

  // Sample
  if (1) {
    double xpos = 0.05 * (xmax-xmin)+xmin;
    double ypos = 0.10 * (ymax-ymin)+ymin;
    TText* text3 = new TText(xpos,ypos,sample.c_str());
    text3->SetTextAlign(12); 
    text3->SetTextSize(0.035);
    text3->Draw();
  }

  // Stats
  gStyle->SetOptStat("i");
  his->SetStats(1);
  TPaveStats* stats = (TPaveStats*)his->GetListOfFunctions()->FindObject("stats"); 
  std::string stats_pos = "br";
  if ( stats ) { 
    stats->SetFillColor(0);
    stats->SetLineColor(0); 
    stats->SetShadowColor(0); 
//.........这里部分代码省略.........
开发者ID:bainbrid,项目名称:usercode,代码行数:101,代码来源:plot_2d.C

示例4: MoveStatsAndDraw

//-------------------------------------------------------------------------------------
void MoveStatsAndDraw (TH1 *data, TH1 *mc, char *dataTitle, char* mcTitle, char* firstline, char* secondline, int log, int col, bool stat, TString cut1, TString cut2, bool movepave){
  c->SetLogy(log);
  mc->Draw();
  data->Draw("pesames");   
  gStyle->SetOptStat(00000000); 
  stat=0;  
  if(stat) gStyle->SetOptStat(1111111111); 

  /*  TPaveText *TITLE = new TPaveText(0.2,0.65,0.55,0.9,"blNDC");
  TITLE->SetFillStyle(4000);
  TITLE->SetFillColor(kWhite);
  TITLE->SetBorderSize(0.1);
  TITLE->SetTextFont(42);
  TITLE->AddText(firstline);
  TITLE->Draw();  */

  if(!movepave) {
  TPaveText *title = new TPaveText(0.2,0.7,0.55,0.93,"blNDC");
  } else {
    //  TPaveText *title = new TPaveText(0.6,0.58,0.95,0.83,"blNDC");
  TPaveText *title = new TPaveText(0.6,0.7,0.95,0.93,"blNDC");
  }
  title->SetFillStyle(4000);
  title->SetFillColor(kWhite);
  title->SetBorderSize(0.1);
  title->SetTextFont(42);
  title->AddText(firstline);
  title->AddText(secondline);
  title->AddText(cut1);
  title->AddText(cut2);
  title->Draw();  
  if(!movepave) {
    TLegend *leg = new TLegend(0.65,0.83,1.,0.93);
  } else {
    TLegend *leg = new TLegend(0.65,0.60,1.,0.7);
  }
  leg->SetFillStyle(4000);
  leg->SetFillColor(kWhite);
  leg->SetBorderSize(0.1);
  leg->SetTextFont(42);
  leg->AddEntry(data,dataTitle,"p");
  leg->AddEntry(mc,mcTitle,"f");
  leg->Draw();

  c->Modified();
  c->Update();



  if(stat){
  TPaveStats * ps = (TPaveStats *) mc->GetListOfFunctions()->FindObject("stats"); 
  TPaveStats * ps2 = (TPaveStats *) data->GetListOfFunctions()->FindObject("stats");
  Int_t ci; 
  ci = TColor::GetColor(col);
  if( ps ){ 
    ps->SetTextColor(1); 
    ps->SetLineColor(col);   
  }
  else std::cout << "Null pointer to TPaveStats: " << ps << std::endl; 
  ps->SetY1NDC(0.40);
  ps->SetY2NDC(0.68);
  if( ps2 ) ps2->SetTextColor(ci); else std::cout << "Null pointer to TPaveStats: " << ps2 << std::endl;
  }
}
开发者ID:aashaqshah,项目名称:cmssw-1,代码行数:65,代码来源:plotDataMC.C

示例5: many_plots2


//.........这里部分代码省略.........
	p->Project(h[2][0], "gtDiff", cVeto && cIso && cT10 && cGamma && cPe && cXYZ && cR);
	p->Project(h[2][1], "gtDiff", !cVeto && cIso && cT10 && cGamma && cPe && cXYZ && cR);
	printf("gtDiff.\n");
	p->Project(h[3][0], "PositronX[0]+2", cVeto && cIso && cT20 && cGamma && cPe && cY && cZ && cR && "PositronX[0] >= 0");
	p->Project(h[3][1], "PositronX[0]+2", !cVeto && cIso && cT20 && cGamma && cPe && cY && cZ && cR && "PositronX[0] >= 0");
	printf("X.\n");
	p->Project(h[4][0], "PositronX[1]+2", cVeto && cIso && cT20 && cGamma && cPe && cX && cZ && cR && "PositronX[1] >= 0");
	p->Project(h[4][1], "PositronX[1]+2", !cVeto && cIso && cT20 && cGamma && cPe && cX && cZ && cR && "PositronX[1] >= 0");
	printf("Y.\n");
	p->Project(h[5][0], "PositronX[2]+0.5", cVeto && cIso && cT20 && cGamma && cPe && cX && cY && cR);
	p->Project(h[5][1], "PositronX[2]+0.5", !cVeto && cIso && cT20 && cGamma && cPe && cX && cY && cR);
	printf("Z.\n");
	p->Project(h[6][0], "NeutronEnergy", cVeto && cIso && cT20 && cGamma && cPe && cY && cZ && cR);
	p->Project(h[6][1], "NeutronEnergy", !cVeto && cIso && cT20 && cGamma && cPe && cY && cZ && cR);
	printf("NE.\n");
	p->Project(h[7][0], "NeutronHits", cVeto && cIso && cT20 && cGamma && cPe && cXYZ && cR);
	p->Project(h[7][1], "NeutronHits", !cVeto && cIso && cT20 && cGamma && cPe && cXYZ && cR);
	printf("NN.\n");
	p->Project(h[8][0], "AnnihilationEnergy", cVeto && cIso && cT20 && cPe && cXYZ && cR);
	p->Project(h[8][1], "AnnihilationEnergy", !cVeto && cIso && cT20 && cPe && cXYZ && cR);
	printf("AE.\n");
	p->Project(h[9][0], "AnnihilationGammas", cVeto && cIso && cT20 && cPe && cXYZ && cR);
	p->Project(h[9][1], "AnnihilationGammas", !cVeto && cIso && cT20 && cPe && cXYZ && cR);
	printf("AG.\n");
	p->Project(h[10][0], "PositronEnergy", cVeto && cIso && cT20 && cGamma && cPe && cXYZ && cR);
	p->Project(h[10][1], "PositronEnergy", !cVeto && cIso && cT20 && cGamma && cPe && cXYZ && cR);
	p->Project(h[11][0], "PositronEnergy", cVeto && cIso && cT20 && cGamma && cPe && cXYZ && cR && cN4 && cT200);
	p->Project(h[11][1], "PositronEnergy", !cVeto && cIso && cT20 && cGamma && cPe && cXYZ && cR && cN4 && cT200);
	
	printf("Projections are done\n");
	
	for (i=0; i<12; i++) {
		for (j=0; j<2; j++) h[i][j]->SetLineWidth(4);
		h[i][0]->SetLineColor(kGreen);
		h[i][1]->SetLineColor(kRed);
		h[i][0]->SetMinimum(0);
		h[i][1]->SetMinimum(0);
	}

//	h[1][0]->Fit("gaus", "0");
//	h[1][1]->Fit("gaus", "0");
	
//	TF1 *fdec = new TF1("FDEC", "[0]*(exp(-x/[1]) - exp(-x/[2]))", 3);
//	fdec->SetParNames("Const", "t_{CAPTURE}", "t_{THERM}");
//	fdec->SetParameters(h[2][0]->Integral()/4, 15, 5);
//	h[2][0]->Fit("FDEC", "0", "", 2, 50);

	for (i=0; i<2; i++) {
		sprintf(str, "CV%d", i);
		cv[i] = new TCanvas(str, "Plots", 1800, 1200);
		cv[i]->Divide(3, 2);
		for (j=0; j<6; j++) {
			cv[i]->cd(j+1);
			h[6*i+j][0]->Draw();
			h[6*i+j][1]->Draw("sames");
			gPad->Update();
			if (i == 0 && j == 1) {
				st = (TPaveStats *) h[6*i+j][0]->FindObject("stats");
				st->SetOptStat(1100);
				st->SetLineColor(kGreen);
				st->SetTextColor(kGreen);
				y = st->GetY1NDC();
				dy = st->GetY2NDC() - y;
				st->SetX1NDC(0.72);
				st = (TPaveStats *) h[6*i+j][1]->FindObject("stats");
				st->SetOptStat(1100);
开发者ID:lab305itep,项目名称:digi,代码行数:67,代码来源:many_plots2.C


注:本文中的TPaveStats::SetLineColor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。