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


C++ TPaveText::Clear方法代码示例

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


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

示例1: simple_overlay


//.........这里部分代码省略.........
TFile *second_file = new TFile("KinematicsPlots_NewBinning.root"); //put name of other file here


for (int i=0; i < num_hists; i++)
	{
	TIter next(first_file->GetListOfKeys());
	TKey *key;
	string hName;

		while((key=(TKey*)next()))
			{	
			hName = key->GetName();
	
			if  (hName.find(first_hname[i]) != -1) 
				{
				first_histogram[i] = (TH1F*)(first_file->Get(hName.c_str()));
				cout << "first_hname[" << i << "]" << first_hname[i] << endl;
				break;
				}		
			}

	TIter next(second_file->GetListOfKeys());

		while((key=(TKey*)next()))
			{
			hName = key->GetName();
		
			if  (hName.find(second_hname[i]) != -1) 
				{
				second_histogram[i] = (TH1F*)(second_file->Get(hName.c_str()));
			cout << "second_hname[" << i << "]" << first_hname[i] << endl;
				break;				
				}					
			}

	TCanvas *c1 = new TCanvas();
	double statXstart[5] = {.8,.8,.8,.8,.8};  
	double statXend[5] = {1.,1.,1.,1.,1.};
	double statYstart[5] = {.80,.70,.60,.50,.40};
	double statYend[5] = {.70,.60,.50,.40,.30};
	Color_t color_array[15] = {kBlue+1,kRed+0,kViolet,kAzure+10,kGreen+2,kBlue+1,kRed+0,kViolet,kAzure+10,kGreen+2,kBlue+1,kRed+0,kViolet,kAzure+10,kGreen+2};
	size_t name_length;
	TPaveText *title = new TPaveText(0.306092,0.9390678,0.693908,0.995,"blNDC");
	gStyle->SetOptTitle(0);
	title->SetBorderSize(0);
	title->SetFillColor(kWhite);
	title->SetTextFont(42);
	TPaveStats *st;	
	
		string directory = "Francesca_Overlaid_Tau_Histograms";
		gSystem->MakeDirectory(directory.c_str());
		directory = directory + "/";

		c1->cd();
		gStyle->SetOptStat("nmre");
		gStyle->SetStatH(0.03);
		gStyle->SetStatW(0.20);

		//TH1F *first_histogram = new TH1F(first_histogram_title, first_histogram_title, 200, 0., 500);
		//TH1F *second_histogram = new TH1F(second_histogram_title, second_histogram_title, 200, 0., 500);	

		first_histogram[i]->SetLineColor(color_array[0]);
		first_histogram[i]->SetLineWidth(2);
	 	first_histogram[i]->SetTitle(first_hname[i].c_str());	// WHAT DOES THIS DO?	eg. does it just set the name for hist title, or also for legend title?
		first_histogram[i]->SetName(first_hname[i].c_str()); // WHAT DOES THIS DO? eg. does it just set name for legend title?
		first_histogram[i]->Draw();
	
		gPad->Update();	
	
		st = (TPaveStats*)first_histogram[i]->FindObject("stats");
		st->SetX1NDC(statXstart[0]); 
		st->SetX2NDC(statXend[0]);
		st->SetY1NDC(statYstart[0]); 
		st->SetY2NDC(statYend[0]);


		second_histogram[i]->SetLineColor(color_array[1]);
		second_histogram[i]->SetLineWidth(2);
		second_histogram[i]->SetTitle(second_hname[i].c_str()); 
		second_histogram[i]->SetName(second_hname[i].c_str());
		second_histogram[i]->Draw("sames");
	
		gPad->Update();		

		st = (TPaveStats*)second_histogram[i]->FindObject("stats");		
		st->SetX1NDC(statXstart[1]); 
		st->SetX2NDC(statXend[1]);
		st->SetY1NDC(statYstart[1]); 
		st->SetY2NDC(statYend[1]);				
		
		c1->BuildLegend(.85,.8,1.,1.);
		c1->SetTitle("Dwarves");
		title->Clear(); //this clears the title for the histogram
		title->AddText((first_hname[i]).c_str()); //this adds text to the TPaveText box that we created before the loop
		title->Draw(); //this draws the TPaveText box with the new text... e.g. it makes our new title
	
		c1->SaveAs((directory + first_hname[i] + ".png").c_str());
	} //close for loop

} //close function bracket
开发者ID:,项目名称:,代码行数:101,代码来源:


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