本文整理汇总了C++中TLegend::SetX1方法的典型用法代码示例。如果您正苦于以下问题:C++ TLegend::SetX1方法的具体用法?C++ TLegend::SetX1怎么用?C++ TLegend::SetX1使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TLegend
的用法示例。
在下文中一共展示了TLegend::SetX1方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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()
示例2: 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);
}
示例3: 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);
}
示例4: EstimateBg_76X
//.........这里部分代码省略.........
if (iMethod==0) printf("| *Sample* | *A (DPhi>%1.1f, %s)* | *B (DPhi<%1.1f, %s)* | *C (DPhi>%1.1f, R>0.4)* | *D = B*C/A pred.* | *D (DPhi<%1.1f, R>0.4) obs.* | *Ratio pred./obs.* | *Pull (pred-obs)/error* | *KS test* |\n", DPHI_CUT, r_sb_cut.str().c_str(), DPHI_CUT, r_sb_cut.str().c_str(), DPHI_CUT, DPHI_CUT);
else if (iMethod==1) printf("| *Sample* | *A%s (%s, <2 tag)* | *B%s (R>%1.1f, <2 tag)* | *C%s (%s, 2 tag)* | *D%s = B%s*C%s/A%s pred.* | *D%s (R>%1.1f, 2 tag) obs.* | *Ratio pred./obs.* | *Pull (pred-obs)/error* | *KS test* |\n", prime, r_sb_cut.str().c_str(), prime, R_CUT, prime, r_sb_cut.str().c_str(), prime, prime, prime, prime, prime, R_CUT);
}
TH1D *h_side_sum, *h_signal_sum;
for (size_t iSample = 0; iSample<samples[iMethod].size(); ++iSample) {
std::string canname =
iMethod==0 ? std::string("DPhiBins")+(ABCD_prime ? "/RBins_0To1HadTop_" : "/RBins_2HadTop_")+samples[iMethod][iSample] :
iMethod==1 ? std::string("RFine/Tau32Cuts_")+(ABCD_prime ? "Fail" : "Pass")+"DPhiCut_"+samples[iMethod][iSample] :
iMethod==2 ? std::string("RFine/Tau32Cuts_")+(ABCD_prime ? "Fail" : "Pass")+"DPhiCut_Background" :
iMethod==3 ? std::string("RFine/Tau32Cuts_")+(ABCD_prime ? "Fail" : "Pass")+"DPhiCut_"+samples[iMethod][iSample] : "";
TCanvas *can = (TCanvas*)(f->Get(canname.c_str()));
can = (TCanvas*)can->Clone();
can->Draw();
TH1D *h_side = (TH1D*)can->GetListOfPrimitives()->At(i_h_side[iMethod]);
TH1D *h_signal = (TH1D*)can->GetListOfPrimitives()->At(i_h_signal[iMethod]);
// Simulate different cross section by scaling a certain background
if (iMethod==1) {
TH1D *h_side_temp_scaled = (TH1D*)h_side->Clone(); h_side_temp_scaled->Scale(scale_factors[iSample]);
TH1D *h_signal_temp_scaled = (TH1D*)h_signal->Clone(); h_signal_temp_scaled->Scale(scale_factors[iSample]);
if (iSample==0) {
h_side_sum = h_side_temp_scaled;
h_signal_sum = h_signal_temp_scaled;
} else {
h_side_sum->Add(h_side_temp_scaled);
h_signal_sum->Add(h_signal_temp_scaled);
}
} else if (iMethod==2) {
h_side = h_side_sum;
h_signal = h_signal_sum;
}
TH1D *h_pred =(TH1D*)h_side->Clone();
if (iMethod!=0&&rebin>1) { h_side->Rebin(rebin); h_signal->Rebin(rebin); h_pred->Rebin(rebin); }
TLegend *leg = (TLegend*)can->GetListOfPrimitives()->At(can->GetListOfPrimitives()->GetEntries()-1);
leg->SetX1(0.35); leg->SetX2(0.65); leg->SetY1(0.6);
// Add ratio plot
int y1 = 350;
int y2 = 150;
int mid2 = 10;
can->Divide(1,2);
// Pad 1 (80+500+20 x 40+500)
TVirtualPad* p = can->cd(1);
p->SetPad(0,(y2+60+mid2)/(y1+y2+100.0+mid2),1,1);
p->SetTopMargin(40.0/(y1+40));
p->SetBottomMargin(0);
p->SetRightMargin(0.05);
p->SetLogy(1);
h_side->GetYaxis()->SetRangeUser(1.00001e-4,1e4);
h_side->Draw("HIST");
h_signal->Draw("SAMEHISTE1");
leg->Draw();
// Pad 2 (80+500+20 x 200+60)
p = can->cd(2);
p->SetGrid(0,1);
p->SetPad(0,0,1,(y2+60+mid2)/(y1+y2+100.0+mid2));
p->SetTopMargin(((float)mid2)/(y2+60+mid2));
p->SetBottomMargin(60.0/(y2+60+mid2));
p->SetRightMargin(0.05);
TH1D* ratio = (TH1D*)h_signal->Clone();
TH1D* div = (TH1D*)h_side->Clone();
//ratio->Scale(1/ratio->GetSumOfWeights());
double sum_bins_ratio = iMethod==0 ? ratio->Integral():
ratio->Integral(ratio->FindBin(R_CUT_LOW),ratio->FindBin(Rranges_ABCD[iMethod][3]));
ratio->Scale(1/sum_bins_ratio);
ratio->SetTitleSize(32.0/(y2+60+mid2),"xyz");
ratio->SetLabelSize(20.0/(y2+60+mid2),"xyz");