本文整理汇总了C++中TPaveLabel::Draw方法的典型用法代码示例。如果您正苦于以下问题:C++ TPaveLabel::Draw方法的具体用法?C++ TPaveLabel::Draw怎么用?C++ TPaveLabel::Draw使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TPaveLabel
的用法示例。
在下文中一共展示了TPaveLabel::Draw方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: help
void help()
{
new TCanvas("chelp","Help on gldemos",200,10,700,600);
TPaveLabel *title = new TPaveLabel(0.04, 0.86, 0.96, 0.98, "These demos show different gl painters.");
title->SetFillColor(32);
title->Draw();
TPaveText *hdemo = new TPaveText(0.04, 0.04, 0.96, 0.8);
hdemo->SetTextAlign(12);
hdemo->SetTextFont(52);
hdemo->SetTextColor(kBlue);
hdemo->AddText("1. Glsurfaces demo shows glsurf4, glsurf1, glsurf3, glsurf1cyl, glsurfpol, gltf3 options.");
hdemo->AddText("2. Glrose demontrates \"glsurf2pol\" drawing option and user-defined palette.");
hdemo->AddText("3. Gltf3 demo shows \"gltf3\" option.");
hdemo->AddText("4. Glbox demo shows \"glbox\" and \"glbox1\" options for TH3.");
hdemo->AddText("5. Glparametric demo shows how to define and display parametric surfaces.");
hdemo->AddText("You can zoom any plot: press 'J', 'K', 'j', 'k' keys, or use mouse wheel.");
hdemo->AddText("Rotate any plot:");
hdemo->AddText(" ---select plot with mouse cursor,");
hdemo->AddText(" ---move mouse cursor, pressing and holding left mouse button ");
hdemo->AddText("Pan plot:");
hdemo->AddText(" ---select with mouse cursor a part of a plot, other than back box planes ,");
hdemo->AddText(" ---move mouse cursor, pressing and holding middle mouse button ");
hdemo->AddText("Selected part of a plot is higlighted (TF3 higlighting is not implemented yet.)");
hdemo->AddText("You can select one of back box planes, press middle mouse button and move cursor-");
hdemo->AddText("this will create \"slice\" (TF does not support yet).");
hdemo->AddText("After the slice was created, you can project it on a back box");
hdemo->AddText(" ---press key 'p' (now implemented only for surf options ).");
hdemo->AddText("Left double click removes all slices/projections.");
hdemo->Draw();
}
示例2: TCanvas
TCanvas *ellipse(){
TCanvas *c1 = new TCanvas("c1");
c1->Range(0,0,1,1);
TPaveLabel *pel = new TPaveLabel(0.1,0.8,0.9,0.95,"Examples of Ellipses");
pel->SetFillColor(42);
pel->Draw();
TEllipse *el1 = new TEllipse(0.25,0.25,.1,.2);
el1->Draw();
TEllipse *el2 = new TEllipse(0.25,0.6,.2,.1);
el2->SetFillColor(6);
el2->SetFillStyle(3008);
el2->Draw();
TEllipse *el3 = new TEllipse(0.75,0.6,.2,.1,45,315);
el3->SetFillColor(2);
el3->SetFillStyle(1001);
el3->SetLineColor(4);
el3->Draw();
TEllipse *el4 = new TEllipse(0.75,0.25,.2,.15,45,315,62);
el4->SetFillColor(5);
el4->SetFillStyle(1001);
el4->SetLineColor(4);
el4->SetLineWidth(6);
el4->Draw();
return c1;
}
示例3: draw_input_labels
void draw_input_labels(Int_t nInputs, Double_t* cy,
Double_t rad, Double_t layerWidth)
{
const Double_t LABEL_HEIGHT = 0.03;
const Double_t LABEL_WIDTH = 0.20;
Double_t width = LABEL_WIDTH + (layerWidth-4*rad);
Double_t margX = 0.01;
Double_t effHeight = 0.8*LABEL_HEIGHT;
TString *varNames = get_var_names(nInputs);
if (varNames == 0) exit(1);
TString input;
for (Int_t i = 0; i < nInputs; i++) {
if (i != nInputs-1) input = varNames[i];
else input = "Bias node";
Double_t x1 = margX;
Double_t x2 = margX + width;
Double_t y1 = cy[i] - effHeight;
Double_t y2 = cy[i] + effHeight;
TPaveLabel *p = new TPaveLabel(x1, y1, x2, y2, input+"", "br");
p->SetFillColor(gStyle->GetTitleFillColor());
p->SetFillStyle(1001);
p->Draw();
if (i == nInputs-1) p->SetTextColor( TMVAGlob::c_NovelBlue );
}
delete[] varNames;
}
示例4: TCanvas
//Draw arrows
//Author: Rene Brun
TCanvas *arrow(){
TCanvas *c1 = new TCanvas("c1");
c1->Range(0,0,1,1);
TPaveLabel *par = new TPaveLabel(0.1,0.8,0.9,0.95,"Examples of various arrow formats");
par->SetFillColor(42);
par->Draw();
TArrow *ar1 = new TArrow(0.1,0.1,0.1,0.7);
ar1->Draw();
TArrow *ar2 = new TArrow(0.2,0.1,0.2,0.7,0.05,"|>");
ar2->SetAngle(40);
ar2->SetLineWidth(2);
ar2->Draw();
TArrow *ar3 = new TArrow(0.3,0.1,0.3,0.7,0.05,"<|>");
ar3->SetAngle(40);
ar3->SetLineWidth(2);
ar3->Draw();
TArrow *ar4 = new TArrow(0.46,0.7,0.82,0.42,0.07,"|>");
ar4->SetAngle(60);
ar4->SetLineWidth(2);
ar4->SetFillColor(2);
ar4->Draw();
TArrow *ar5 = new TArrow(0.4,0.25,0.95,0.25,0.15,"<|>");
ar5->SetAngle(60);
ar5->SetLineWidth(4);
ar5->SetLineColor(4);
ar5->SetFillStyle(3008);
ar5->SetFillColor(2);
ar5->Draw();
return c1;
}
示例5: glbox
void glbox()
{
gStyle->SetCanvasPreferGL(kTRUE);
TCanvas *c = new TCanvas("glc","TH3 Drawing", 100, 10, 850, 400);
TPaveLabel *title = new TPaveLabel(0.04, 0.86, 0.96, 0.98,
"\"glbox\" and \"glbox1\" options for TH3.");
title->SetFillColor(32);
title->Draw();
TPad *boxPad = new TPad("box", "box", 0.02, 0.02, 0.48, 0.82);
TPad *box1Pad = new TPad("box1", "box1", 0.52, 0.02, 0.98, 0.82);
boxPad->Draw();
box1Pad->Draw();
TH3F *h31 = new TH3F("h31", "h31", 10, -1, 1, 10, -1, 1, 10, -1, 1);
h31->FillRandom("gaus");
h31->SetFillColor(2);
boxPad->cd();
h31->Draw("glbox");
TH3F *h32 = new TH3F("h32", "h32", 10, -2, 2, 10, -1, 1, 10, -3, 3);
h32->FillRandom("gaus");
h32->SetFillColor(4);
box1Pad->cd();
h32->Draw("glbox1");
}
示例6: testRoot
void testRoot() {
//Fill a 1-D histogram from a parametric function
// To see the output of this macro, click begin_html <a href="gif/fillrandom.gif">here</a>. end_html
//Author: Rene Brun
TCanvas *c1 = new TCanvas("c1","The FillRandom example",200,10,700,900);
c1->SetFillColor(18);
TPad* pad1 = new TPad("pad1","The pad with the function",0.05,0.50,0.95,0.95,21);
TPad* pad2 = new TPad("pad2","The pad with the histogram",0.05,0.05,0.95,0.45,21);
pad1->Draw();
pad2->Draw();
pad1->cd();
gBenchmark->Start("fillrandom");
//
// A function (any dimension) or a formula may reference
// an already defined formula
//
TFormula* form1 = new TFormula("form1","abs(sin(x)/x)");
TF1* sqroot = new TF1("sqroot","x*gaus(0) + [3]*form1",0,10);
sqroot->SetParameters(10,4,1,20);
pad1->SetGridx();
pad1->SetGridy();
pad1->GetFrame()->SetFillColor(42);
pad1->GetFrame()->SetBorderMode(-1);
pad1->GetFrame()->SetBorderSize(5);
sqroot->SetLineColor(4);
sqroot->SetLineWidth(6);
sqroot->Draw();
TPaveLabel* lfunction = new TPaveLabel(5,39,9.8,46,"The sqroot function");
lfunction->SetFillColor(41);
lfunction->Draw();
c1->Update();
//
// Create a one dimensional histogram (one float per bin)
// and fill it following the distribution in function sqroot.
//
pad2->cd();
pad2->GetFrame()->SetFillColor(42);
pad2->GetFrame()->SetBorderMode(-1);
pad2->GetFrame()->SetBorderSize(5);
TH1F* h1f = new TH1F("h1f","Test random numbers",200,0,10);
h1f->SetFillColor(45);
h1f->FillRandom("sqroot",10000);
h1f->Draw();
c1->Update();
//
// Open a ROOT file and save the formula, function and histogram
//
TFile myfile("fillrandom.root","RECREATE");
form1->Write();
sqroot->Write();
h1f->Write();
gBenchmark->Show("fillrandom");
}
示例7: KolmogorovTest
////////////////////////////////////////////////////////////
//
// This function performs a compatibility test between two
// histogram based on the Kolmogorov-Smirnof algorithm. It
// also prints the value in a TPaveLabel at the upper-right
// corner.
// The return value contains the result of the test
//
double KolmogorovTest(TH1 *h1, TH1 *h2){
double mya_array[1300], myb_array[1300];
vector<double> mya;
vector<double> myb;
for (int i=0; i<h1->GetNbinsX(); i++){
mya.push_back(h1->GetBinContent(i+1));
myb.push_back(h2->GetBinContent(i+1));
}
sort(mya.begin(),mya.end());
sort(myb.begin(),myb.end());
copy(mya.begin(),mya.end(),mya_array);
copy(myb.begin(),myb.end(),myb_array);
const int nbinsa = h1->GetNbinsX();
const int nbinsb = h2->GetNbinsX();
double kstest = TMath::KolmogorovTest(nbinsa, mya_array,
nbinsb, myb_array,
"UOX");
if (DEBUGP) cout << " + KS value = " << kstest << endl;
// Create text with the value
TString legend = Form("KS=%4.2f", kstest);
// Create a pave text to put the value inside
TPaveLabel* pl = new TPaveLabel(0.79,0.91,0.93,0.96, legend.Data(), "NDC");
// Tune style
//pl->SetTextSize(0.04);
pl->SetLineColor(41);
pl->SetLineWidth(1);
pl->SetLineStyle(1);
pl->SetFillColor(41);
pl->SetBorderSize(3);
if (kstest < 0.7)
pl->SetTextColor(kRed);
pl->Draw();
return kstest;
}
示例8: DoFit
void DoFit(const char* fitter, TVirtualPad *pad, Int_t npass) {
TStopwatch timer;
TVirtualFitter::SetDefaultFitter(fitter);
pad->SetGrid();
fitFcn->SetParameters(100,0,0,2,7);
fitFcn->Update();
timer.Start();
histo->Fit("fitFcn","0");
timer.Stop();
histo->Draw();
Double_t cputime = timer.CpuTime();
printf("%s, npass=%d : RT=%7.3f s, Cpu=%7.3f s\n",fitter,npass,timer.RealTime(),cputime);
TPaveLabel *p = new TPaveLabel(0.5,0.7,0.85,0.8,Form("%s CPU= %g s",fitter,cputime),"brNDC");
p->Draw();
pad->Update();
}
示例9: first
void first() {
TCanvas *nut = new TCanvas("nut", "FirstSession",100,10,700,900);
nut->Range(0,0,20,24);
nut->SetFillColor(10);
nut->SetBorderSize(2);
TPaveLabel *pl = new TPaveLabel(3,22,17,23.7,
"My first ROOT interactive session","br");
pl->SetFillColor(18);
pl->Draw();
TText t(0,0,"a");
t.SetTextFont(62);
t.SetTextSize(0.025);
t.SetTextAlign(12);
t.DrawText(2,20.3,"ROOT is based on CINT, a powerful C/C++ interpreter.");
t.DrawText(2,19.3,"Blocks of lines can be entered within {...}.");
t.DrawText(2,18.3,"Previous typed lines can be recalled.");
t.SetTextFont(72);
t.SetTextSize(0.026);
t.DrawText(3,17,"Root > float x=5; float y=7;");
t.DrawText(3,16,"Root > x*sqrt(y)");
t.DrawText(3,14,
"Root > for (int i=2;i<7;i++) printf(\"sqrt(%d) = %f\\n\",i,sqrt(i));");
t.DrawText(3,10,"Root > TF1 f1(\"f1\",\"sin(x)/x\",0,10)");
t.DrawText(3, 9,"Root > f1.Draw()");
t.SetTextFont(81);
t.SetTextSize(0.018);
t.DrawText(4,15,"(float) 13.2288f");
t.DrawText(4,13.3,"sqrt(2) = 1.414214");
t.DrawText(4,12.7,"sqrt(3) = 1.732051");
t.DrawText(4,12.1,"sqrt(4) = 2.000000");
t.DrawText(4,11.5,"sqrt(5) = 2.236068");
t.DrawText(4,10.9,"sqrt(6) = 2.449490");
TPad *pad = new TPad("pad","pad",.2,.05,.8,.35);
pad->Draw();
pad->cd();
pad->SetGrid();
TF1 *f1 = new TF1("f1","sin(x)/x",0,10);
f1->Draw();
}
示例10: glrose
// Render a TF2 looking like a rose.
// Author: Timur Pocheptsov
void glrose()
{
//Define and set user's palette,
//use polar system.
const Int_t paletteSize = 10;
Float_t rgb[paletteSize * 3] =
{0.80f, 0.55f, 0.40f,
0.85f, 0.60f, 0.45f,
0.90f, 0.65f, 0.50f,
0.95f, 0.70f, 0.55f,
1.f, 0.75f, 0.60f,
1.f, 0.80f, 0.65f,
1.f, 0.85f, 0.70f,
1.f, 0.90f, 0.75f,
1.f, 0.95f, 0.80f,
1.f, 1.f, 0.85f};
Int_t palette[paletteSize] = {0};
for (Int_t i = 0; i < paletteSize; ++i)
palette[i] = TColor::GetColor(rgb[i * 3], rgb[i * 3 + 1], rgb[i * 3 + 2]);
gStyle->SetPalette(paletteSize, palette);
gStyle->SetCanvasPreferGL(1);
TCanvas *cnv = new TCanvas("glc", "Surface sample", 200, 10, 600, 550);
TPaveLabel *title = new TPaveLabel(0.04, 0.86, 0.96, 0.98,
"\"glsurf2pol\" option + user defined palette.");
title->SetFillColor(32);
title->Draw();
TPad *rosePad = new TPad("box", "box", 0.04, 0.04, 0.96, 0.8);
rosePad->Draw();
TF2 *fun = new TF2("a", "cos(y)*sin(x)+cos(x)*sin(y)", -6, 6, -6, 6);
fun->SetContour(paletteSize);
fun->SetNpx(30);
fun->SetNpy(30);
rosePad->cd();
fun->Draw("glsurf2pol");
}
示例11: draw_layer_labels
void draw_layer_labels(Int_t nLayers)
{
const Double_t LABEL_HEIGHT = 0.03;
const Double_t LABEL_WIDTH = 0.20;
Double_t effWidth = 0.8*(1.0-LABEL_WIDTH)/nLayers;
Double_t height = 0.8*LABEL_HEIGHT;
Double_t margY = LABEL_HEIGHT - height;
for (Int_t i = 0; i < nLayers; i++) {
TString label = Form("Layer %i", i);
Double_t cx = i*(1.0-LABEL_WIDTH)/nLayers+1.0/(2.0*nLayers)+LABEL_WIDTH;
Double_t x1 = cx-0.8*effWidth/2.0;
Double_t x2 = cx+0.8*effWidth/2.0;
Double_t y1 = margY;
Double_t y2 = margY + height;
TPaveLabel *p = new TPaveLabel(x1, y1, x2, y2, label+"", "br");
p->SetFillColor(gStyle->GetTitleFillColor());
p->SetFillStyle(1001);
p->Draw();
}
}
示例12: StEEmcDbMaker
void
show
(
char* inpDir = "", // MuDST directory
char* inpFile = "show.lis", // MuDST file(s);
char* outFile = "show.root",// output tree file
Int_t nFiles = 50, // # of MuDST file(s)
Int_t nEvents = 100 // # of events
)
// remeber to adjust dbase timestamp below !!!!
// what a ... design
{
//gErrorIgnoreLevel=1999;
// load root/root4star libraries
gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
loadSharedLibraries();
// load more libraries :)
gSystem->Load("libmysqlclient");
gSystem->Load("libGeom");
gSystem->Load("StDbLib");
gSystem->Load("StDbBroker");
gSystem->Load("St_db_Maker");
// load even more libraries (EEMC stuff)
gSystem->Load("StEEmcUtil");
gSystem->Load("StEEmcDbMaker");
gSystem->Load("StEEmcPoolTTM");
// create the chain
chain = new StChain("StChain");
//
now = new TDatime;
// for display
TCanvas *c1 = new TCanvas("eemc","eemc",10,10,1000,1000);
TPaveLabel *tlab = new TPaveLabel(-0.99,+0.99,+0.99,+0.90,
"EEMC TOWERS & TPC TRACKS Piotr A Zolnierczuk (IU)");
eventInfo = new TPaveText (-0.99,-0.99,+0.0 ,-0.75);
dateInfo = new TPaveLabel(+0.60,-0.99,+0.99,-0.95,now->AsString());
TGeoManager *gm = new TGeoManager("eemc", "eemc tower display");
TGeoVolume *top = gm->MakeBox("star",0, 200., 200., 350.);
TGeoVolume *smbox = gm->MakeBox("smbox1",0, 2., 2., 2.);
smbox->SetLineColor(kRed);
// eemc
eemc = new EEmcTTDisplay();
eemc->SetMagneticField(0.5); // in Tesla
eemc->SetShowExtrapolatedTracks(true);
TGeoTranslation *etra = new TGeoTranslation(0.0,0.0,0.5*(eemc->getZ1()+eemc->getZ2()));
top->AddNode(smbox, 1,NULL);
top->AddNode(eemc(),1,etra);
gm->SetTopVolume(top);
gm->CloseGeometry();
gm->SetVisLevel(4);
gm->SetVisOption(0);
c1->SetTheta(90);
c1->SetPhi(0);
top->Draw();
tlab->Draw();
gPad->Update();
// now we add Makers to the chain... some of that is black magic :)
muDstMk = new StMuDstMaker(0,0,inpDir,inpFile,"",nFiles); // muDST main chain
StMuDbReader *db = StMuDbReader::instance(); // need the database
St_db_Maker *dbMk = new St_db_Maker("StarDb", "MySQL:StarDb"); // need another db(?)
new StEEmcDbMaker("eemcDb"); // need EEMC database
// now comment in/out/change the below if you want it your way
dbMk->setTimeStampDay(20040331); // format: yyyymmdd
// finally after so many lines we arrive at the good stuff
ttm = new EEmcTTMMaker ("TTM",muDstMk,eemcDbMk);
ttm->Summary(cout); //
StMuDebug::setLevel(0);
chain->Init();
StEEmcDb *eemcDb = (StEEmcDb*)chain->GetDataSet("StEEmcDb");
eemcDb->setSectors(1,12); // request EEMC DB for sectors you need (dafault:1-12)
eemcDb->setPreferedFlavor("onlped","eemcPMTped"); // request alternative flavor
chain->ls(3);
//---------------------------------------------------
next();
}
示例13: zlljets_ZpT_recoGenAna
//.........这里部分代码省略.........
//cout << " **************** check ************** " << endl;
for (Int_t j = 0; j < nFiles; j++) {
hZpTreco[j]->SetStats(kFALSE); // to avoid drawing statistic box
hZpTreco[j]->SetLineColor(histColor[j]);
// no need to use TH1::Scale() between reco and gen of Z->mumu or Z->ee, because histogram are filled for the same set of events, so integral
// should be the same in principle
//hZpTreco[j]->SetFillColorAlpha(histColor[j], 0.80);
hZpTgen[j]->SetStats(kFALSE); // to avoid drawing statistic box
hZpTgen[j]->SetLineColor(histColor[j+2]);
hZpTrecoGenRatio[j]->SetStats(kFALSE);
//hZpTrecoGenRatio[j]->SetLineColor(histColor[j]);
hZpTrecoGenRatio_pdf[j]->SetStats(kFALSE);
hZpTrecoGenRatio_pdf[j]->SetLineColor(histColor[j+2]);
HZtoLLPt_RecoGenRatio_pdf_inRange[j]->SetStats(kFALSE);
HZtoLLPt_RecoGenRatio_pdf_inRange[j]->SetLineColor(histColor[j*2]);
}
TPad *subpad1 = NULL; // will use it to access specific subpad in canvas
TPad *subpad2 = NULL;
TCanvas *cZtomumuPtRecoGen = new TCanvas("cZtomumuPtRecoGen","",700,700);
TLegend *legZtomumuPtRecoGen = new TLegend(0.70,0.7,0.89,0.89);
subpad1 = new TPad("pad1","",0.0,0.36,1.0,1.0);
subpad1->SetLogy();
subpad1->SetBottomMargin(0);
subpad2 = new TPad("pad2","",0.0,0.0,1.0,0.36);
subpad2->SetGrid();
subpad2->SetTopMargin(0);
subpad2->SetBottomMargin(0.2);
subpad1->Draw();
subpad2->Draw();
//cout <<"Drawing histograms and ratio"<<endl;
subpad1->cd();
// hZpTreco[0]->GetXaxis()->SetTitle("Z_{pT}[GeV]");
// hZpTreco[0]->GetXaxis()->SetTitleSize(0.04);
//hZpTreco[0]->GetXaxis()->SetLabelSize(0.04);
hZpTreco[0]->GetYaxis()->SetTitle("# events");
hZpTreco[0]->GetYaxis()->SetTitleSize(0.04);
hZpTreco[0]->GetYaxis()->SetLabelSize(0.04);
hZpTreco[0]->GetYaxis()->CenterTitle();
//hZpTreco[0]->GetYaxis()->SetLabelSize(0.04);
hZpTreco[0]->Draw("HE");
hZpTgen[0]->Draw("HE SAME");
legZtomumuPtRecoGen->AddEntry(hZpTreco[0],"Z(#mu#mu) reco","l");
legZtomumuPtRecoGen->AddEntry(hZpTgen[0],"Z(#mu#mu) gen","l");
gStyle->SetStatStyle(0);
legZtomumuPtRecoGen->Draw();
legZtomumuPtRecoGen->SetMargin(0.3);
legZtomumuPtRecoGen->SetBorderSize(0);
subpad2->cd();
hZpTrecoGenRatio[0]->GetXaxis()->SetLabelSize(0.08);
hZpTrecoGenRatio[0]->GetXaxis()->SetTitle("Z_{pT}[GeV]");
hZpTrecoGenRatio[0]->GetXaxis()->SetTitleSize(0.07);
hZpTrecoGenRatio[0]->GetXaxis()->SetTitleOffset(1.2);
hZpTrecoGenRatio[0]->GetYaxis()->SetLabelSize(0.07);
hZpTrecoGenRatio[0]->GetYaxis()->SetTitle("reco/gen ZpT");
hZpTrecoGenRatio[0]->GetYaxis()->SetTitleSize(0.07);
hZpTrecoGenRatio[0]->GetYaxis()->SetTitleOffset(0.5);
hZpTrecoGenRatio[0]->GetYaxis()->CenterTitle();
hZpTrecoGenRatio[0]->Draw("E");
hZpTrecoGenRatio[0]->SetMarkerStyle(7); //medium dot
cZtomumuPtRecoGen->SaveAs( (plotDirectoryPath + cZtomumuPtRecoGen->GetName() + suffix + plotFileExtension).c_str() );
示例14: h1draw
void h1draw()
{
// We attach (or generate) the ROOT file in $ROOTSYS/tutorials/hsimple.root
// or $PWD/hsimple.root
// We draw one histogram in different formats
//Author: Rene Brun
TFile *example = TFile::Open("hsimple.root");
if (!example) return;
example->ls();
TH1 *hpx = (TH1*)example->Get("hpx");
TCanvas *c1 = new TCanvas("c1","Histogram Drawing Options",200,10,700,900);
TPad *pad1 = new TPad("pad1",
"The pad with the function",0.03,0.62,0.50,0.92,21);
TPad *pad2 = new TPad("pad2",
"The pad with the histogram",0.51,0.62,0.98,0.92,21);
TPad *pad3 = new TPad("pad3",
"The pad with the histogram",0.03,0.02,0.97,0.57,21);
pad1->Draw();
pad2->Draw();
pad3->Draw();
// Draw a global picture title
TPaveLabel *title = new TPaveLabel(0.1,0.94,0.9,0.98,
"Drawing options for one dimensional histograms");
title->SetFillColor(16);
title->SetTextFont(52);
title->Draw();
// Draw histogram hpx in first pad with the default option.
pad1->cd();
pad1->GetFrame()->SetFillColor(18);
hpx->SetFillColor(45);
hpx->DrawCopy();
TPaveLabel *label1 = new TPaveLabel(-3.5,700,-1,800,"Default option");
label1->SetFillColor(42);
label1->Draw();
// Draw hpx as a lego. Clicking on the lego area will show
// a "transparent cube" to guide you rotating the lego in real time.
pad2->cd();
hpx->DrawCopy("lego1");
TPaveLabel *label2 = new TPaveLabel(-0.72,0.74,-0.22,0.88,"option Lego1");
label2->SetFillColor(42);
label2->Draw();
TPaveLabel *label2a = new TPaveLabel(-0.93,-1.08,0.25,-0.92,
"Click on lego to rotate");
label2a->SetFillColor(42);
label2a->Draw();
// Draw hpx with its errors and a marker.
pad3->cd();
pad3->SetGridx();
pad3->SetGridy();
pad3->GetFrame()->SetFillColor(18);
hpx->SetMarkerStyle(21);
hpx->Draw("e1p");
TPaveLabel *label3 = new TPaveLabel(2,600,3.5,650,"option e1p");
label3->SetFillColor(42);
label3->Draw();
// The following illustrates how to add comments using a PaveText.
// Attributes of text/lines/boxes added to a PaveText can be modified.
// The AddText function returns a pointer to the added object.
TPaveText *pave = new TPaveText(-3.78,500,-1.2,750);
pave->SetFillColor(42);
TText *t1=pave->AddText("You can move");
t1->SetTextColor(4);
t1->SetTextSize(0.05);
pave->AddText("Title and Stats pads");
pave->AddText("X and Y axis");
pave->AddText("You can modify bin contents");
pave->Draw();
c1->Update();
}
示例15: file
void file(){
TCanvas *c1 = new TCanvas("c1","ROOT File description",200,10,700,550);
c1->Range(0,-0.25,21,14);
TPaveLabel *title = new TPaveLabel(5,12,15,13.7,c1->GetTitle());
title->SetFillColor(16);
title->Draw();
// horizonthal file layout
TPave *file = new TPave(1,8.5,20,11);
file->SetFillColor(11);
file->Draw();
TPave *fileh = new TPave(1,8.5,2.5,11);
fileh->SetFillColor(44);
fileh->Draw();
TPave *lrh = new TPave(2.5,8.5,3.3,11,1);
lrh->SetFillColor(33);
lrh->Draw();
lrh->DrawPave(6.9,8.5,7.7,11,1);
lrh->DrawPave(10.5,8.5,11.3,11,1);
lrh->DrawPave(14.5,8.5,15.3,11,1);
TLine *ldot = new TLine(1,8.5,0.5,6.5);
ldot->SetLineStyle(2);
ldot->Draw();
ldot->DrawLine(2.5, 8.5, 9.4, 6.5);
ldot->DrawLine(10.5, 8.5, 10, 6.5);
ldot->DrawLine(11.3, 8.5, 19.5, 6.5);
TLine *line = new TLine(2.6,11,2.6,11.5);
line->Draw();
line->DrawLine(2.6,11.5,7,11.5);
TArrow *arrow = new TArrow(7,11.5,7,11.1,0.01,"|>");
arrow->SetFillStyle(1001);
arrow->Draw();
line->DrawLine( 7, 8.5, 7, 8.0);
line->DrawLine( 7, 8.0, 10.6, 8);
arrow->DrawArrow( 10.6,8, 10.6, 8.4,0.01,"|>");
line->DrawLine( 10.6, 11, 10.6, 11.5);
line->DrawLine( 10.6, 11.5, 14.6, 11.5);
arrow->DrawArrow( 14.6,11.5, 14.6,11.1,0.01,"|>");
line->DrawLine( 14.6, 8.5, 14.6, 8.0);
line->DrawLine( 14.6, 8.0, 16, 8);
ldot->DrawLine(16, 8, 19, 8);
TText *vert = new TText(1.5,9.75,"File");
vert->SetTextAlign(21);
vert->SetTextAngle(90);
vert->SetTextSize(0.025);
vert->Draw();
vert->DrawText(2.0, 9.75,"Header");
vert->DrawText(2.9, 9.75,"Logical Record");
vert->DrawText(3.2, 9.75,"Header");
vert->DrawText(7.3, 9.75,"Logical Record");
vert->DrawText(7.6, 9.75,"Header");
vert->DrawText(10.9,9.75,"Logical Record");
vert->DrawText(11.2,9.75,"Header");
vert->DrawText(14.9,9.75,"Logical Record");
vert->DrawText(15.2,9.75,"Header");
TText *hori = new TText(4.75,10,"Object");
hori->SetTextAlign(22);
hori->SetTextSize(0.035);
hori->Draw();
hori->DrawText(4.75, 9.5,"Data");
hori->DrawText(9.2, 10,"Deleted");
hori->DrawText(9.2, 9.5,"Object");
line->DrawLine( 6.9, 8.5, 10.5, 11);
line->DrawLine( 6.9, 11, 10.5, 8.5);
TText *tbig = new TText(17,9.75,"............");
tbig->SetTextAlign(22);
tbig->SetTextSize(0.03);
tbig->Draw();
tbig->DrawText(2.6, 7, "fBEGIN");
tbig->DrawText(20., 7, "fEND");
arrow->DrawArrow( 2.6,7, 2.6,8.4,0.01,"|>");
arrow->DrawArrow( 20,7, 20,8.4,0.01,"|>");
//file header
TPaveText *header = new TPaveText(0.5,.2,9.4,6.5);
header->SetFillColor(44);
header->Draw();
TText *fh=header->AddText("File Header");
fh->SetTextAlign(22);
fh->SetTextSize(0.04);
header->SetTextSize(0.027);
header->SetTextAlign(12);
header->AddText(" ");
header->AddLine(0,0,0,0);
header->AddText("\"root\": Root File Identifier");
header->AddText("fVersion: File version identifier");
header->AddText("fBEGIN: Pointer to first data record");
header->AddText("fEND: Pointer to first free word at EOF");
header->AddText("fSeekFree: Pointer to FREE data record");
header->AddText("fNbytesFree: Number of bytes in FREE");
header->AddText("fNfree: Number of free data records");
header->AddText("fNbytesName: Number of bytes in name/title");
header->AddText("fUnits: Number of bytes for pointers");
header->AddText("fCompress: Compression level");
//logical record header
TPaveText *lrecord = new TPaveText(10,0.2,19.5,6.5);
lrecord->SetFillColor(33);
//.........这里部分代码省略.........