本文整理汇总了C++中TLegend::SetY2方法的典型用法代码示例。如果您正苦于以下问题:C++ TLegend::SetY2方法的具体用法?C++ TLegend::SetY2怎么用?C++ TLegend::SetY2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TLegend
的用法示例。
在下文中一共展示了TLegend::SetY2方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: piechart
void piechart()
{
Float_t vals[] = {.2,1.1,.6,.9,2.3};
Int_t colors[] = {2,3,4,5,6};
Int_t nvals = sizeof(vals)/sizeof(vals[0]);
TCanvas *cpie = new TCanvas("cpie","TPie test",700,700);
cpie->Divide(2,2);
TPie *pie1 = new TPie("pie1",
"Pie with offset and no colors",nvals,vals);
TPie *pie2 = new TPie("pie2",
"Pie with radial labels",nvals,vals,colors);
TPie *pie3 = new TPie("pie3",
"Pie with tangential labels",nvals,vals,colors);
TPie *pie4 = new TPie("pie4",
"Pie with verbose labels",nvals,vals,colors);
cpie->cd(1);
pie1->SetAngularOffset(30.);
pie1->SetEntryRadiusOffset( 4, 0.1);
pie1->SetRadius(.35);
pie1->Draw("3d");
cpie->cd(2);
pie2->SetEntryRadiusOffset(2,.05);
pie2->SetEntryLineColor(2,2);
pie2->SetEntryLineWidth(2,5);
pie2->SetEntryLineStyle(2,2);
pie2->SetEntryFillStyle(1,3030);
pie2->SetCircle(.5,.45,.3);
pie2->Draw("rsc");
cpie->cd(3);
pie3->SetY(.32);
pie3->GetSlice(0)->SetValue(.8);
pie3->GetSlice(1)->SetFillStyle(3031);
pie3->SetLabelsOffset(-.1);
pie3->Draw("3d t nol");
TLegend *pieleg = pie3->MakeLegend();
pieleg->SetY1(.56); pieleg->SetY2(.86);
cpie->cd(4);
pie4->SetRadius(.2);
pie4->SetLabelsOffset(.01);
pie4->SetLabelFormat("#splitline{%val (%perc)}{%txt}");
pie4->Draw("nol <");
}
示例2: plot_efficiencies
//.........这里部分代码省略.........
frame->GetXaxis()->SetTitle( xtit );
frame->GetYaxis()->SetTitle( ytit );
TMVAGlob::SetFrameStyle( frame, 1.0 );
frame->Draw();
Int_t color = 1;
Int_t nmva = 0;
TKey *key, *hkey;
TString hNameRef = "effBvsS";
if (type == 2) hNameRef = "rejBvsS";
TList hists;
TList methods;
UInt_t nm = TMVAGlob::GetListOfMethods( methods );
// TIter next(file->GetListOfKeys());
TIter next(&methods);
// loop over all methods
while (key = (TKey*)next()) {
TDirectory * mDir = (TDirectory*)key->ReadObj();
TList titles;
UInt_t ninst = TMVAGlob::GetListOfTitles(mDir,titles);
TIter nextTitle(&titles);
TKey *titkey;
TDirectory *titDir;
while ((titkey = TMVAGlob::NextKey(nextTitle,"TDirectory"))) {
titDir = (TDirectory *)titkey->ReadObj();
TString methodTitle;
TMVAGlob::GetMethodTitle(methodTitle,titDir);
TIter nextKey( titDir->GetListOfKeys() );
while ((hkey = TMVAGlob::NextKey(nextKey,"TH1"))) {
TH1 *h = (TH1*)hkey->ReadObj();
TString hname = h->GetName();
if (hname.Contains( hNameRef ) && hname.BeginsWith( "MVA_" )) {
h->SetLineWidth(3);
h->SetLineColor(color);
color++; if (color == 5 || color == 10 || color == 11) color++;
h->Draw("csame");
hists.Add(h);
nmva++;
}
}
}
}
while (hists.GetSize()) {
TListIter hIt(&hists);
TH1* hist(0);
Double_t largestInt=-1;
TH1* histWithLargestInt(0);
while ((hist = (TH1*)hIt())!=0) {
Double_t integral = hist->Integral(1,hist->FindBin(0.9999));
if (integral>largestInt) {
largestInt = integral;
histWithLargestInt = hist;
}
}
if (histWithLargestInt == 0) {
cout << "ERROR - unknown hist \"histWithLargestInt\" --> serious problem in ROOT file" << endl;
break;
}
legend->AddEntry(histWithLargestInt,TString(histWithLargestInt->GetTitle()).ReplaceAll("MVA_",""),"l");
hists.Remove(histWithLargestInt);
}
// rescale legend box size
// current box size has been tuned for 3 MVAs + 1 title
if (type == 1) {
dyH *= (1.0 + Float_t(nmva - 3.0)/4.0);
legend->SetY1( y0H - dyH );
}
else {
dyH *= (Float_t(nmva - 3.0)/4.0);
legend->SetY2( y0H + dyH);
}
// redraw axes
frame->Draw("sameaxis");
legend->Draw("same");
// ============================================================
if (__PLOT_LOGO__) TMVAGlob::plot_logo();
// ============================================================
c->Update();
TString fname = "plots/" + hNameRef;
if (TString(BinDir->GetName()).Contains("multicut")){
TString fprepend(BinDir->GetName());
fprepend.ReplaceAll("multicutMVA_","");
fname = "plots/" + fprepend + "_" + hNameRef;
}
if (__SAVE_IMAGE__) TMVAGlob::imgconv( c, fname );
return;
}
示例3: drawClarkAnalysis
void NLSimpleGuiWindow::drawClarkAnalysis( const ConsentrationGraph &xGraph,
const ConsentrationGraph &yGraph,
bool isCgmsVMeter )
{
ui->tabWidget->setCurrentWidget(ui->clarkeGridTab);
cleanupClarkAnalysis();
TimeDuration cmgsDelay(0,0,0,0);
if( isCgmsVMeter )
{
TCanvas *can = ui->clarkResultsWidget->GetCanvas();
can->cd();
can->SetEditable( kTRUE );
TPaveText *delayErrorEqnPt = new TPaveText(0, 0, 1.0, 1.0, "NDC");
delayErrorEqnPt->SetBorderSize(0);
delayErrorEqnPt->SetTextAlign(12);
cmgsDelay = m_model->findCgmsDelayFromFingerStick();
double sigma = 1000.0 * m_model->findCgmsErrorFromFingerStick(cmgsDelay);
sigma = static_cast<int>(sigma + 0.5) / 10.0; //nearest tenth of a percent
string delayStr = "Delay=";
delayStr += boost::posix_time::to_simple_string(cmgsDelay).substr(3,5);
delayStr += " ";
ostringstream uncertDescript;
uncertDescript << "#sigma_{cgms}^{finger}=" << sigma << "%";
delayErrorEqnPt->AddText( uncertDescript.str().c_str() );
delayErrorEqnPt->AddText( delayStr.c_str() );
delayErrorEqnPt->Draw();
can->SetEditable( kFALSE );
can->Update();
}//if( isCgmsVMeter )
TCanvas *can = ui->clarkeErrorGridWidget->GetCanvas();
can->cd();
can->SetEditable( kTRUE );
vector<TObject *> clarkesObj;
clarkesObj = getClarkeErrorGridObjs( yGraph, xGraph, cmgsDelay, true );
assert( dynamic_cast<TH1 *>(clarkesObj[0]) );
dynamic_cast<TH1 *>(clarkesObj[0])->GetYaxis()->SetTitleOffset(1.3);
clarkesObj[0]->Draw("SCAT");
clarkesObj[1]->Draw("SCAT SAME");
clarkesObj[2]->Draw("SCAT SAME");
clarkesObj[3]->Draw("SCAT SAME");
clarkesObj[4]->Draw("SCAT SAME");
TLegend *leg = dynamic_cast<TLegend *>( clarkesObj[5] );
assert( leg );
//Now draw all the boundry lines
for( size_t i=6; i < clarkesObj.size(); ++i ) clarkesObj[i]->Draw();
can->SetEditable( kFALSE );
can->Update();
// can->ResizePad();
// ui->clarkeErrorGridWidget->Refresh();
can = ui->clarkeLegendWidget->GetCanvas();
can->cd();
leg->SetX1(-0.1);
leg->SetX2(1.1);
leg->SetY1(0.0);
leg->SetY2(1.0);
leg->Draw();
can->SetEditable( kFALSE );
can->Update();
}// void NLSimpleGuiWindow::drawPredictedClarkAnalysis()
示例4: plot
//.........这里部分代码省略.........
input.close();
printf(" \n");
printf(" Found %d measurements.\n",nLines);
printf(" Maximum tranfer rate at: %6.2f MB/sec\n",maxRate);
printf(" \n");
// Open a canvas
TCanvas *cv = new TCanvas();
cv->Draw();
if (nLines<1) {
printf(" WARNING - no measurements selected.\n");
plotFrame(double(xStart),double(xEnd));
double dX = double(xEnd)-double(xStart);
TText *plotText = new TText(xMin-dX*0.14,0.-(maxRate*1.2*0.14),text.Data());
printf("Text size: %f\n",plotText->GetTextSize());
plotText->SetTextSize(0.04);
plotText->SetTextColor(kBlue);
plotText->Draw();
cv->SaveAs(pngFileName.Data());
return;
}
const int numVals = nLines;
double xVals[numVals];
double y1Vals[numVals];
double y2Vals[numVals];
input.open(timeSeriesFile.Data());
// Second loop to register the measured values
//--------------------------------------------
Int_t i = 0;
while (1) {
// read in
input >> time >> rate >> nConn;
// check it worked
if (!input.good())
break;
// check whether in our requested time window
if (xStart>0 && xStart>time)
continue;
if (xEnd>0 && xEnd<time)
continue;
xVals[i] = time;
y1Vals[i] = rate;
y2Vals[i] = nConn;
i++;
}
input.close();
// Make a good frame
plotFrame(xMin,xMax,maxRate);
double dX = double(xEnd)-double(xStart);
TText *plotText = new TText(xMin-dX*0.14,0.-(maxRate*1.2*0.14),text.Data());
plotText->SetTextSize(0.04);
plotText->SetTextColor(kBlue);
plotText->Draw();
// Prepare our graphs
TGraph* graph1 = new TGraph(numVals, xVals, y1Vals);
graph1->SetLineColor(2);
graph1->SetLineWidth(2);
graph1->SetMarkerColor(4);
graph1->SetMarkerStyle(21);
graph1->SetMarkerSize(0.4);
TGraph* graph2 = new TGraph(numVals, xVals, y2Vals);
graph2->SetLineColor(3);
graph2->SetLineWidth(2);
graph2->SetMarkerColor(4);
graph2->SetMarkerStyle(20);
graph2->SetMarkerSize(0.4);
// Through them into the multigraph
TMultiGraph *mg = new TMultiGraph();
mg->Add(graph1,"lp");
mg->Add(graph2,"lp");
// Draw the graphs
mg->Draw("CP");
// Add a nice legend to the picture
TLegend *leg = new TLegend(0.4,0.6,0.89,0.89);
//leg->SetTextSize(0.036);
leg->SetX1(0.15);
leg->SetX2(0.30);
leg->SetY1(0.95);
leg->SetY2(0.85);
leg->SetBorderSize(0);
leg->SetFillStyle(0);
leg->AddEntry(graph2,"number of tranfers","lp");
leg->AddEntry(graph1,"data tranfer rate","lp");
leg->Draw();
cv->SaveAs(pngFileName);
}
示例5: macro_MakeFRClosureTest
//.........这里部分代码省略.........
for (unsigned int j = 0; j < 4; ++j) {
if (!plotClosureTest[j]) continue;
for (unsigned int p = 0; p < 4; ++p) {
if (!plotHisto[p]) continue;
TCanvas *c0 = new TCanvas(canvasName[j] + acroSuffix[p], canvasTitle[j] + suffix[p], 100, 100, 800, 600);
c0->cd();
c0->SetBorderMode(0);
c0->SetFrameBorderMode(0);
c0->SetFillColor(0);
c0->SetFrameFillColor(0);
c0->SetLogy();
gStyle->SetTitleFont(font);
gStyle->SetLabelFont(font);
gStyle->SetOptStat(0);
gStyle->SetPadTickX(1);
gStyle->SetPadTickY(1);
// get the histograms
input.cd(folderGsfGsfHisto[j]);
TH1F *histoGsfGsf = (TH1F *)gDirectory->Get(gsfGsfHisto[j] + acroSuffix[p]);
input.cd(folderHeepGsfHisto[j]);
TH1F *histoHeepGsf = (TH1F *)gDirectory->Get(heepGsfHisto[j] + acroSuffix[p]);
input.cd(folderDataHisto);
TH1F *histoData = (TH1F *)gDirectory->Get("histoHeepHeepMass" + acroSuffix[p]);
TH1F *histoGsfGsfRebinned = (TH1F *)histoGsfGsf->Rebin(nBins, gsfGsfHisto[j] + "Rebinned" + acroSuffix[p], binArray);
TH1F *histoHeepGsfRebinned = (TH1F *)histoHeepGsf->Rebin(nBins, heepGsfHisto[j] + "Rebinned" + acroSuffix[p], binArray);
TH1F *histoDataRebinned = (TH1F *)histoData->Rebin(nBins, "histoHeepHeepMassRebinned" + acroSuffix[p], binArray);
histoGsfGsfRebinned->SetLineColor(4);
histoGsfGsfRebinned->SetMarkerColor(4);
histoGsfGsfRebinned->SetMarkerStyle(20);
histoGsfGsfRebinned->SetTitleFont(font);
histoHeepGsfRebinned->SetLineColor(2);
histoHeepGsfRebinned->SetMarkerColor(2);
histoHeepGsfRebinned->SetMarkerStyle(21);
histoHeepGsfRebinned->SetTitleFont(font);
histoHeepGsfRebinned->GetYaxis()->SetTitleFont(font);
histoHeepGsfRebinned->GetYaxis()->SetLabelFont(font);
histoHeepGsfRebinned->GetXaxis()->SetLabelFont(font);
histoDataRebinned->SetLineColor(1);
histoDataRebinned->SetMarkerColor(1);
histoDataRebinned->SetMarkerStyle(20);
histoDataRebinned->SetTitleFont(font);
histoDataRebinned->GetYaxis()->SetTitleFont(font);
histoDataRebinned->GetYaxis()->SetLabelFont(font);
histoDataRebinned->GetXaxis()->SetLabelFont(font);
sStream.str("");
if (binning.size() > 1)
sStream << "# of events / bin";
else
sStream << "# of events / " << binning.begin()->second << "GeV";
if (plotData) {
histoDataRebinned->SetMinimum(yAxisMin);
histoDataRebinned->SetTitle(canvasTitle[j] + suffix[p]);
histoDataRebinned->GetYaxis()->SetTitle(sStream.str().c_str());
histoDataRebinned->Draw();
histoHeepGsfRebinned->Draw("sames");
} else {
histoHeepGsfRebinned->SetTitle(canvasTitle[j] + suffix[p]);
histoHeepGsfRebinned->GetYaxis()->SetTitle(sStream.str().c_str());
histoHeepGsfRebinned->Draw();
}
histoGsfGsfRebinned->Draw("sames");
sStream.str("");
sStream << "#sqrt{s} = 8TeV, #int L dt = " << lumi << "pb^{-1}";
TPaveLabel *label0 = new TPaveLabel(0.6, 0.79, 0.9, 0.89, sStream.str().c_str(), "brNDC");
label0->SetFillColor(0);
label0->SetFillStyle(0);
label0->SetBorderSize(0);
label0->SetTextSize(0.30);
label0->SetTextFont(font);
label0->Draw("sames");
TPaveLabel *label1 = new TPaveLabel(0.7, 0.89, 0.91, 0.98, "CMS preliminary", "brNDC");
label1->SetFillColor(0);
label1->SetFillStyle(0);
label1->SetBorderSize(0);
label1->SetTextSize(0.40);
label1->SetTextFont(font);
label1->Draw("sames");
TLegend *legend = new TLegend(0.38, 0.6, 0.53, 0.9);
if (!plotData) legend->SetY2(0.8);
legend->SetTextSize(0.03);
legend->SetTextFont(font);
legend->SetBorderSize(0);
legend->SetFillStyle(0);
if (plotData) legend->AddEntry(histoDataRebinned, "Data", "lep");
legend->AddEntry(histoHeepGsfRebinned, legendHeepGsf[j], "lep");
legend->AddEntry(histoGsfGsfRebinned, legendGsfGsf[j], "lep");
legend->Draw("sames");
} // end loop over eta ranges
} // end loop over corrections
input.Close();
}
示例6: plot
//.........这里部分代码省略.........
//printf(" Min / Time / Max: %d %d %d\n",xStart,time,xEnd);
// check whether in our requested time window
if (xStart>0 && xStart>time)
continue;
if (xEnd>0 && xEnd<time)
continue;
// Show what we are reading
if (nLines < 5)
printf(" time=%d, nFails=%d\n",time, nFail);
// Determine plot maximum
if (nFail > max)
max = nFail;
nLines++;
}
input.close();
printf(" \n");
printf(" Found %d measurements.\n",nLines);
printf(" Maximum failures at: %6.2f in 90 sec\n",max);
printf(" \n");
// Open a canvas
TCanvas *cv = new TCanvas();
cv->SetLogy(kTRUE);
cv->Draw();
if (nLines<1) {
printf(" WARNING - no measurements selected.\n");
plotFrame(double(xStart),double(xEnd));
overlayFrame(text);
cv->SaveAs(pngFileName.Data());
return;
}
const int numVals = nLines;
double xVals[numVals];
double yVals[numVals];
input.open(timeSeriesFile.Data());
// Second loop to register the measured values
//--------------------------------------------
Int_t i = 0;
while (1) {
// read in
input >> time >> nFail;
// check it worked
if (!input.good())
break;
// check whether in our requested time window
if (xStart>0 && xStart>time)
continue;
if (xEnd>0 && xEnd<time)
continue;
xVals[i] = time;
yVals[i] = nFail;
i++;
}
input.close();
// Make a good frame
plotFrame(xMin,xMax,max);
// Prepare our graphs
TGraph* graph1 = new TGraph(numVals, xVals, yVals);
graph1->SetLineColor(2);
graph1->SetLineWidth(2);
graph1->SetMarkerColor(4);
graph1->SetMarkerStyle(21);
graph1->SetMarkerSize(0.4);
// Through them into the multigraph
TMultiGraph *mg = new TMultiGraph();
mg->Add(graph1,"lp");
// Draw the graphs
mg->Draw("CP");
// Add a nice legend to the picture
TLegend *leg = new TLegend(0.4,0.6,0.89,0.89);
leg->SetX1(0.15);
leg->SetX2(0.30);
leg->SetY1(0.95);
leg->SetY2(0.85);
leg->SetBorderSize(0);
leg->SetFillStyle(0);
leg->AddEntry(graph1,"number of failures","lp");
leg->Draw();
overlayFrame(text);
cv->SaveAs(pngFileName);
}