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


C++ TImage::WriteImage方法代码示例

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


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

示例1: hist_to_png_h1

void hist_to_png_h1(TH1F * h_c, TH1F* h_e, TH1F* h_f, TString saveTitle, TString type_string)
{
  TCanvas *cPNG = new TCanvas(saveTitle,"",700,500);
  TImage *img = TImage::Create();
  char * type = type_string.Data();
  gStyle->SetOptStat(0);
  gPad->SetLogy();
  auto legend = new TLegend(0.7,0.7,0.9,0.9);
  legend->SetTextSize(0.06);
  legend->AddEntry(h_c,"CEMC","l");
  legend->AddEntry(h_e,"EEMC","l");
  legend->AddEntry(h_f,"FEMC","l");
  
  if(strcmp(type,"spatial")==0)
    {  
      h_e->GetXaxis()->SetTitle("Extrapolation distance from cluster [cm]");
      h_e->GetYaxis()->SetTitle("Counts");
    }
  h_e->Draw();
  h_c->Draw("SAME");
  h_f->Draw("SAME");
  legend->Draw();
  img->FromPad(cPNG);
  img->WriteImage(saveTitle);
}
开发者ID:sPHENIX-Collaboration,项目名称:analysis,代码行数:25,代码来源:track2cluster_plot.C

示例2: SaveOpenSpectras

void SaveOpenSpectras() {
	char *spectra_names[] =
		{"CB-Spectra",
		 "TAPS-BaF2-Spectra",
		 "TAPS-PbWO4-Spectra",
		 "TAPS-Veto-Spectra",
		 "Tagger-Spectra",
		 "EPT-Spectra",
		 "PID-Spectra",
		 "MWPC-Spectra",
		 "Scaler-Spectra", // aka trigger spectra...
		 "Livetimes-Spectra",
		 "Physics-Spectra",
		 0};

	// clean up directory...
	printf("\nDelete all PNG images on daq-master:/home/a2cb/OnlineSpectra\n");
	stringstream CmdStr;
	CmdStr << "rm /home/a2cb/acqu/OnlineSpectra/*.png";
	system(CmdStr.str().c_str());

	// prepare elog command, note the blank space at every line!
	stringstream elog_cmd;
	elog_cmd << "echo Run " << gAR->GetRunNumber() << " Online Spectra | ";
	elog_cmd << "elog -h elog.office.a2.kph -u a2online a2messung ";
	elog_cmd << "-l 'Main Group Logbook' -a Experiment='EPT test 2014-07' ";
	elog_cmd << "-a Author='PLEASE FILL IN' -a Type=Routine ";
	elog_cmd << "-a Subject='Online Spectra Run " << gAR->GetRunNumber() << "' ";
	
	// Save Spectra
	UInt_t i = 0;
	char spectra_title[50];
	char spectra_filename[100];
	
	while (spectra_names[i]){
		sprintf(spectra_title, "%s", spectra_names[i]);
		sprintf(spectra_filename, "/home/a2cb/acqu/OnlineSpectra/%02i_%s.png", i, spectra_names[i]);
		gSystem->ProcessEvents();

		if (gROOT->FindObject(spectra_title)) {

			TImage *img = TImage::Create();
			img->FromPad((TVirtualPad*)gROOT->FindObject(spectra_title));
			img->WriteImage(spectra_filename);
			delete img;
			elog_cmd << "-f " << spectra_filename << " ";
			printf("Spectra saved: %s\n", spectra_title);
		} else {
			printf("Spectra not found: %s\n", spectra_title);
		}
		i++;
	}


	printf("\nPosting all PNG images to the Elog\n");
	system(elog_cmd.str().c_str());
	printf("\nPLEASE EDIT THE ELOG ENTRY TO MAKE IT COMPLETE!\n\n");
}
开发者ID:RoddyMacrae,项目名称:acqu-A2,代码行数:58,代码来源:SaveSpectras.C

示例3: save_image

/**
 * \brief saves the plotted image
 * Saves the plotter image to the given filename
 * \param std::string filename - output filename for the image also determines the image type ( ".png" -> png etc.)
 * \return bool on success
 */
bool Plotter::save_image(std::string filename){
  try{
    TImage *img = TImage::Create();
    img->FromPad(canvas);
    img->WriteImage(filename.c_str());
    return true;
  }catch(std::runtime_error &e){
    std::cerr << e.what() << std::endl;
    return false;
  }
}
开发者ID:wutzi15,项目名称:plot_lib,代码行数:17,代码来源:plot_lib.cpp

示例4: pad2png

void pad2png()
{
   TCanvas *c = new TCanvas;
   TH1F *h = new TH1F("gaus", "gaus", 100, -5, 5);
   h->FillRandom("gaus", 10000);
   h->Draw();

   gSystem->ProcessEvents();

   TImage *img = TImage::Create();

   img->FromPad(c);

   img->WriteImage("canvas.png");
}
开发者ID:MycrofD,项目名称:root,代码行数:15,代码来源:pad2png.C

示例5: hist_to_png

void hist_to_png(TH2F * h, TString saveTitle, TString type_string)
{
  TCanvas *cPNG = new TCanvas(saveTitle,"",700,500);
  TImage *img = TImage::Create();
  char * type = type_string.Data();
  gPad->SetLogz();
  gStyle->SetOptStat(0);
  if(strcmp(type,"phi")==0)
    {
      h->GetXaxis()->SetTitle("Track Phi");
      h->GetYaxis()->SetTitle("Cluster Phi");
    }
  else if(strcmp(type,"eta")==0)
    {
      h->GetXaxis()->SetTitle("Track Eta");
      h->GetYaxis()->SetTitle("Cluster Eta"); 
    }
  else if(strcmp(type,"theta")==0)
    {
      h->GetXaxis()->SetTitle("Track Theta");
      h->GetYaxis()->SetTitle("Cluster Theta");
    }
  else if(strcmp(type,"mom")==0)
    {
      h->GetXaxis()->SetTitle("Track Momentum [GeV]");
      h->GetYaxis()->SetTitle("Cluster Momentum [GeV]");
    }
  else if(strcmp(type,"posx")==0)
    {
      h->GetXaxis()->SetTitle("Track Position X [cm]");
      h->GetYaxis()->SetTitle("Cluster Position X [cm]");
    }
  else if(strcmp(type,"posy")==0)
    {
      h->GetXaxis()->SetTitle("Track Position Y [cm]");
      h->GetYaxis()->SetTitle("Cluster Position Y [cm]");
    }
  else if(strcmp(type,"posz")==0)
    {  
      h->GetXaxis()->SetTitle("Track Position Z [cm]");
      h->GetYaxis()->SetTitle("Cluster Position Z [cm]");
    }
  h->Draw("colz9");
  img->FromPad(cPNG);
  img->WriteImage(saveTitle);

  delete img;
}
开发者ID:sPHENIX-Collaboration,项目名称:analysis,代码行数:48,代码来源:track2cluster_plot.C

示例6: pad2png

void pad2png()
{
   // Create a canvas and save as png.
   //Author: Valeriy Onuchin

   TCanvas *c = new TCanvas;
   TH1F *h = new TH1F("gaus", "gaus", 100, -5, 5);
   h->FillRandom("gaus", 10000);
   h->Draw();

   gSystem->ProcessEvents();

   TImage *img = TImage::Create();

   //img->FromPad(c, 10, 10, 300, 200);
   img->FromPad(c);

   img->WriteImage("canvas.png");

   delete h;
   delete c;
   delete img;
}
开发者ID:ancapopescu13,项目名称:root,代码行数:23,代码来源:pad2png.C

示例7: ratioplot2


//.........这里部分代码省略.........
			cout << Type[j] << " h1, h2 constructed" << endl;

			//h1->
			// Define the Canvas
			//TCanvas *c = new TCanvas("c", "canvas", 800, 800);

			// Upper plot will be in pad1
			pad1 = new TPad("pad1", "pad1", 0, 0.3, 1, 1.0);
			pad1->SetBottomMargin(0); // Upper and lower plot are joined
			pad1->SetGridx();         // Vertical grid
			pad1->Draw();             // Draw the upper pad: pad1
			pad1->cd();               // pad1 becomes the current pad
			//h1->SetStats(0);          // No statistics on upper plot

			cout << "h1, h2 before draw" << endl;
			h2->Draw();               // Draw h1
			h1->Draw("same");         // Draw h2 on top of h1
			
			cout << "h1, h2 draw.." << endl;
			// Do not draw the Y axis label on the upper plot and redraw a small
			// axis instead, in order to avoid the first label (0) to be clipped.
			//h1->GetYaxis()->SetLabelSize(0.);
			//TGaxis *axis = new TGaxis( -5, 20, -5, 220, 20,220,510,"");
			//TGaxis *axis = (TGaxis *)h1->GetGaxis();
			//axis->SetLabelFont(43); // Absolute font size in pixel (precision 3)
			//axis->SetLabelSize(15);
			//axis->Draw();

			// lower plot will be in pad
			c->cd();          // Go back to the main canvas before defining pad2
			pad2 = new TPad("pad2", "pad2", 0, 0.05, 1, 0.3);
			pad2->SetTopMargin(0.01);
			pad2->SetBottomMargin(0.2);
			pad2->SetGridx(); // vertical grid
			pad2->Draw();
			pad2->cd();       // pad2 becomes the current pad

			// Define the ratio plot
			h3 = (TH1F*)h1->Clone("h3");
			h3->SetLineColor(kBlack);
			h3->SetMinimum(0);  // Define Y ..
			h3->SetMaximum(2); // .. range
			h3->Sumw2();
			h3->SetStats(0);      // No statistics on lower plot
			h3->Divide(h2);
			h3->SetMarkerStyle(21);
			h3->Draw("ep");       // Draw the ratio plot

			// h1 settings
			h1->SetLineColor(kBlue+1);
			h1->SetLineWidth(2);

			// Y axis h1 plot settings
			h1->GetYaxis()->SetTitleSize(20);
			h1->GetYaxis()->SetTitleFont(43);
			h1->GetYaxis()->SetTitleOffset(1.55);

			// h2 settings
			h2->SetLineColor(kRed);
			h2->SetLineWidth(2);

			// Ratio plot (h3) settings
			h3->SetTitle(""); // Remove the ratio title

			// Y axis ratio plot settings
			//h3->GetYaxis()->SetTitle("ratio h1/h2 ");
			h3->GetYaxis()->SetNdivisions(505);
			h3->GetYaxis()->SetTitleSize(20);
			h3->GetYaxis()->SetTitleFont(43);
			h3->GetYaxis()->SetTitleOffset(1.55);
			h3->GetYaxis()->SetLabelFont(43); // Absolute font size in pixel (precision 3)
			h3->GetYaxis()->SetLabelSize(15);

			// X axis ratio plot settings
			h3->GetXaxis()->SetTitleSize(20);
			h3->GetXaxis()->SetTitleFont(43);
			h3->GetXaxis()->SetTitleOffset(4.);
			h3->GetXaxis()->SetLabelFont(43); // Absolute font size in pixel (precision 3)
			h3->GetXaxis()->SetLabelSize(15);

			//TImage *img = TImage::Create();

			img->FromPad(c);
			img->WriteImage(Type[j]+"_Tightminus_"+Cut[i]+".png");

			cout << Type[j] << "_Tightminus_" << Cut[i] << ".png output" << endl;
			//delete h3;
			//delete h2;
			//delete h1;
			//delete pad1;
			//delete pad2;
			delete c;


			//delete f1;

			cout << "file closed" << endl;
		} // iteration Type end
	} // iteration Cut end
}
开发者ID:doodoong,项目名称:intern,代码行数:101,代码来源:ratioplot2.C

示例8: multiDrawComp2


//.........这里部分代码省略.........

    p1_4->SetName(profname);
    p1_4->SetTitle(histtitle);
    p1_4->SetMaximum(yrange*1.3);

    p1_4->SetLineColor(prof1_4);
    p1_4->SetMarkerColor(prof1_4);
    p1_4->SetMarkerStyle(marker4);

    p1_4->GetXaxis()->SetTitle(xtitle);
    p1_4->GetXaxis()->SetLabelFont(42);
    p1_4->GetXaxis()->SetLabelSize(0.035);
    p1_4->GetXaxis()->SetTitleSize(0.045);
    p1_4->GetXaxis()->SetTitleFont(42);
    p1_4->GetYaxis()->SetTitle(ytitle);
    p1_4->GetYaxis()->SetLabelFont(42);
    p1_4->GetYaxis()->SetLabelSize(0.035);
    p1_4->GetYaxis()->SetTitleSize(0.045);
    p1_4->GetYaxis()->SetTitleFont(42);
    p1_4->GetXaxis()->SetRange(startplot,endplot);
    p1_4->GetZaxis()->SetLabelFont(42);
    p1_4->GetZaxis()->SetLabelSize(0.035);
    p1_4->GetZaxis()->SetTitleSize(0.035);
    p1_4->GetZaxis()->SetTitleFont(42);
    p1_4->Draw("hist p sames");  

    gPad->Update();
    
    if(!single) {
    profname[0] = '\0';
    strcat(profname, dataset4);
    strcat(profname, " ");
    strcat(profname, id2);

    p2_4->SetName(profname);
    p2_4->SetTitle(histtitle);
    p2_4->SetMaximum(yrange*1.3);
    
    p2_4->SetLineColor(prof2_4);
    p2_4->SetMarkerColor(prof2_4);
    p2_4->SetMarkerStyle(marker4);
    p2_4->SetMarkerSize(.7);
    
    p2_4->GetXaxis()->SetTitle(xtitle);
    p2_4->GetXaxis()->SetLabelFont(42);
    p2_4->GetXaxis()->SetLabelSize(0.035);
    p2_4->GetXaxis()->SetTitleSize(0.045);
    p2_4->GetXaxis()->SetTitleFont(42);
    p2_4->GetYaxis()->SetTitle(ytitle);
    p2_4->GetYaxis()->SetLabelFont(42);
    p2_4->GetYaxis()->SetLabelSize(0.035);
    p2_4->GetYaxis()->SetTitleSize(0.045);
    p2_4->GetYaxis()->SetTitleFont(42);
    p2_4->GetXaxis()->SetRange(startplot,endplot);
    p2_4->GetZaxis()->SetLabelFont(42);
    p2_4->GetZaxis()->SetLabelSize(0.035);
    p2_4->GetZaxis()->SetTitleSize(0.035);
    p2_4->GetZaxis()->SetTitleFont(42);
    p2_4->Draw("hist p sames");  

    gPad->Update();
    }//Second Profile
  }

 
  TLegend *leg = new TLegend(0.5043103,0.6666667,0.8821839,0.8776371,NULL,"brNDC");
  leg->SetBorderSize(1);
  leg->SetLineColor(1);
  leg->SetLineStyle(1);
  leg->SetLineWidth(1);
  leg->SetFillColor(0);
  leg->SetFillStyle(1001);
  leg->AddEntry(p1_1,p1_1->GetName(),"lp");
  if(!single) leg->AddEntry(p2_1,p2_1->GetName(),"lp");
  leg->AddEntry(p1_2,p1_2->GetName(),"lp");
  if(!single) leg->AddEntry(p2_2,p2_2->GetName(),"lp");

  if(filenum >= 3){
    leg->AddEntry(p1_3,p1_3->GetName(),"lp");
    if(!single) leg->AddEntry(p2_3,p2_3->GetName(),"lp");
  }

  if(filenum >= 4){
    leg->AddEntry(p1_4,p1_4->GetName(),"lp");
    if(!single) leg->AddEntry(p2_4,p2_4->GetName(),"lp");
  }
  
  leg->Draw();
  
  c->Modified();
  c->cd();
  c->SetSelected(c);
  
  TImage *img = TImage::Create();
  
  img->FromPad(c);
  img->WriteImage(outfile);
  

}
开发者ID:BaylorCMS,项目名称:HcalPromptAnalysis,代码行数:101,代码来源:multiDrawComp2.C

示例9: hw1


//.........这里部分代码省略.........
  gDirectory->Get(histvName[1])->Draw("esame");
  gDirectory->Get(histvName[0])->Draw("esame");
  */
  TCanvas* canvas = new TCanvas("myc","HW1",800,600);

  TH1F* h1 = new TH1F("h1","Landau 100 entries",15,-3,10);
  TH1F* h2 = new TH1F("h2","Landau 1000 entries",60,-3,10);
  TH1F* h3 = new TH1F("h3","Landau 10000 entries",200,-3,10);
  h1->FillRandom("mylandau",100);
  h2->FillRandom("mylandau",1000);
  h3->FillRandom("mylandau",10000);
  h3->GetXaxis()->SetTitle("x");
  h3->GetXaxis()->CenterTitle(true);
  h3->GetYaxis()->SetTitle("Entries");
  h3->GetYaxis()->CenterTitle(true);
  h3->SetStats(kFALSE);

  TF1* fit3 = new TF1("fit3",landauf,-3,10,3);
  fit3->SetParameters(1.0,2,1);
  h3->SetMarkerColor(kRed);
  h3->SetLineColor(kRed);
  fit3->SetLineColor(kRed+2);
  h3->Fit("fit3","q","e");

  TF1* fit2 = new TF1("fit2",landauf,-3,10,3);
  fit2->SetParameters(1.0,2,1);
  h2->SetMarkerColor(kBlue);
  h2->SetLineColor(kBlue);
  fit2->SetLineColor(kBlue+2);
  h2->Fit("fit2","q","esame");

  TF1* fit1 = new TF1("fit1",landauf,-3,10,3);
  fit1->SetParameters(1.0,2,1);
  h1->SetMarkerColor(kGreen);
  h1->SetLineColor(kGreen);
  fit1->SetLineColor(kGreen+2);
  h1->Fit("fit1","q","esame");

  double h1M = h1->GetMean();
  double h1R = h1->GetRMS();
  double h1S = h1->GetSkewness();
  double h2M = h2->GetMean();
  double h2R = h2->GetRMS();
  double h2S = h2->GetSkewness();
  double h3M = h3->GetMean();
  double h3R = h3->GetRMS();
  double h3S = h3->GetSkewness();

  cout<<setprecision(4);
  cout<<"+----+--------+--------+--------+"<<endl;
  cout<<"|hist|  Mean  |  RMS   |skewness|"<<endl;
  cout<<"+----+--------+--------+--------+"<<endl;
  cout<<"+  1 |"<<setw(8)<<h1M<<"|"<<setw(8)<<h1R<<"|"<<setw(8)<<h1S<<"|"<<endl;
  cout<<"+----+--------+--------+--------+"<<endl;
  cout<<"+  2 |"<<setw(8)<<h2M<<"|"<<setw(8)<<h2R<<"|"<<setw(8)<<h2S<<"|"<<endl;
  cout<<"+----+--------+--------+--------+"<<endl;
  cout<<"+  3 |"<<setw(8)<<h3M<<"|"<<setw(8)<<h3R<<"|"<<setw(8)<<h3S<<"|"<<endl;
  cout<<"+----+--------+--------+--------+"<<endl;

  TPaveStats *ptstats = new TPaveStats(0.5747126,0.6334746,0.9353448,0.934322,"brNDC");
  ptstats->SetName("stats");
  ptstats->SetBorderSize(1);
  ptstats->SetFillColor(0);
  ptstats->SetLineWidth(2);
  ptstats->SetTextAlign(12);
  ptstats->SetTextFont(132);
  ptstats->AddText(" hist   Mean     RMS    skewness ");
  ostringstream os;
  cout<<setprecision(4);
  os<<"   1  "<<setw(8)<<h1M<<" "<<setw(8)<<h1R<<" "<<setw(8)<<h1S<<" ";
  ptstats->AddText(os.str().c_str());
  os.str(string());
  os<<"   2  "<<setw(8)<<h2M<<" "<<setw(8)<<h2R<<" "<<setw(8)<<h2S<<" ";
  ptstats->AddText(os.str().c_str());
  os.str(string());
  os<<"   3  "<<setw(8)<<h3M<<" "<<setw(8)<<h3R<<" "<<setw(8)<<h3S<<" ";
  ptstats->AddText(os.str().c_str());
  ptstats->SetOptStat(0);
  ptstats->SetOptFit(111);
  ptstats->Draw();
  h1->GetListOfFunctions()->Add(ptstats);
  ptstats->SetParent(h1);

  TLegend *leg = new TLegend(0.1582915,0.7237762,0.3580402,0.9230769,NULL,"brNDC");
  leg->AddEntry(h1,"100 entries","pe");
  leg->AddEntry(h2,"1000 entries","pe");
  leg->AddEntry(h3,"10000 entries","pe");
  leg->SetFillColor(0);
  leg->Draw();

  //export png
  TImage *img = TImage::Create();
  img->FromPad(canvas);
  img->WriteImage("hw1.png");
  //delete img;


  //return
  return 0;
}
开发者ID:DingXuefeng,项目名称:hw1,代码行数:101,代码来源:hw1.C

示例10: diaphragm_spectrum

void diaphragm_spectrum()
{
    gROOT->Reset();
    TFile * tfin = new TFile("data/kaon_mcraytracing.root");
    TH2D * hphotons;
    tfin->GetObject( "CedarMCTester/Photons/RayTracing/Diaphragm", hphotons );

    TCanvas c("c","c", 600, 600 );
    c.cd();
    gStyle->SetOptStat(0);
    gStyle->SetGridColor( kGray);
    c.SetRightMargin(0.15);
    c.SetLeftMargin(0.12);
    c.SetGrid();

    plot_diaphragm_spectrum( hphotons);

    c.Print("output/diaphragm_photons.pdf", "pdf" );

    TH2D * hphotoelectrons;
    tfin->GetObject( "CedarMCTester/Photoelectrons/RayTracing/Diaphragm", hphotoelectrons );
    plot_diaphragm_spectrum( hphotoelectrons);

    c.Print("output/diaphragm_photoelectrons.pdf", "pdf" );

    TCanvas * c2 = new TCanvas( "c2", "c2", 900, 300 );
    c2->cd();
    TFile * tfinpion = new TFile("data/pion_mcraytracing.root");
    TH2D * hpepion;
    tfinpion->GetObject( "CedarMCTester/Photoelectrons/RayTracing/Diaphragm", hpepion );

    gROOT->GetColor( kRed+2)->SetAlpha(0.02);
    hphotoelectrons->SetMarkerColor( kRed+2 );
    hphotoelectrons->Draw();
    hphotoelectrons->GetXaxis()->SetRangeUser(98, 104 );
    gROOT->GetColor( kBlue+2)->SetAlpha(0.02);
    hpepion->SetMarkerColor( kBlue+2 );
    hpepion->Draw("same");


    c2->SetGrid();
    c2->Print("output/diaphragm_pionvskaon.pdf", "pdf" );

    TImage * img = TImage::Create();
    img->FromPad(c2);
    img->WriteImage( "output/diaphragm_pionvskaon.png" );

    TH1D * hkaon = hphotoelectrons->ProjectionX( "hkaon", 0, -1 );
    TH1D * hpion = hpepion->ProjectionX( "hpion", 0, -1 );

    TCanvas * c3 = new TCanvas( "c2", "c2", 900, 500 );
    c3->cd();
    gROOT->GetColor( kRed+2)->SetAlpha(1);
    gROOT->GetColor( kBlue+2)->SetAlpha(1);
    hkaon->SetLineColor( kRed+2);
    hkaon->Scale(1.0/11.0);
    hpion->SetLineColor( kBlue+2);
    hpion->GetXaxis()->SetRangeUser(98,104);
    hpion->SetBit( TH1::kNoTitle, true );
    hpion->Draw();
    hkaon->SetBit( TH1::kNoTitle, true );
    hkaon->Draw("same");
    c3->SetGrid();
    c3->Print("output/diaphragm_pkcomp.pdf", "pdf" );
}
开发者ID:francisnewson,项目名称:pycedar,代码行数:65,代码来源:diaphragm_spectrum.c

示例11: trans_graph

void trans_graph()
{
   // remember if  we are in batch mode
   Bool_t batch = gROOT->IsBatch();

   // switch to batch mode
   gROOT->SetBatch(kTRUE);

   // execute graph.C macro
   gROOT->Macro("$ROOTSYS/tutorials/graphs/graph.C");

   // create gVirtualPS object
   TImageDump dmp("dummy.png");
   TImage *fore = dmp.GetImage();  // image associated with image_dump

   // resize canvas
   gPad->SetCanvasSize(400, 300);
   gPad->Paint(); // paint gPad on fore image associated with TImageDump

   // open background image
   TImage *back = TImage::Open("$ROOTSYS/tutorials/image/rose512.jpg");

   // choose colors to be transparent
   TColor *bk1 = gROOT->GetColor(gPad->GetFillColor());
   TColor *bk2 = gROOT->GetColor(gPad->GetFrame()->GetFillColor());
   UInt_t rgb1 = color2rgb(bk1);
   UInt_t rgb2 = color2rgb(bk2);

   // get directly accessible ARGB array
   UInt_t *argb = fore->GetArgbArray();
   UInt_t w = fore->GetWidth();
   UInt_t h = fore->GetHeight();

   // scan all pixels in fore image and
   // make rgb1, rgb2 colors transparent.
   for (UInt_t i = 0; i < h; i++) {
      for (UInt_t j = 0; j < w; j++) {
         Int_t idx = i*w + j;

         // RGB part of ARGB color
         UInt_t col = argb[idx] & 0xffffff;

         // 24..31 bits define transparency of the color in the range 0 - 0xff
         // for example, 0x00000000 - black color with 100% transparency
         //              0xff000000 - non-transparent black color

         if ((col == rgb1) || (col == rgb2)) { //
            argb[idx] = 0; // 100% transparent
         } else {
            argb[idx] = 0xff000000 + col;  // make other pixels non-transparent
         }
      }
   }

   // alphablend back and fore images
   back->Merge(fore, "alphablend", 20, 20);

   // write result image in PNG format
   back->WriteImage("trans_graph.png");
   printf("*************** File trans_graph.png created ***************\n");

   delete back;

   // switch back to GUI mode
   if (!batch) gROOT->SetBatch(kFALSE);
}
开发者ID:MycrofD,项目名称:root,代码行数:66,代码来源:trans_graph.C

示例12: main


//.........这里部分代码省略.........
	gr->GetHistogram("empty")->GetYaxis()->SetTitle("Messurement"); 
	gr->GetHistogram("empty")->GetZaxis()->SetTitle("Intensity in dB");
	gr->GetHistogram("empty")->GetXaxis()->SetTitleOffset(1.5);
	gr->GetHistogram("empty")->GetYaxis()->SetTitleOffset(1.5);
	gr->GetHistogram("empty")->GetZaxis()->SetTitleOffset(1.5);
	gr->GetHistogram("empty")->GetZaxis()->SetRangeUser(-70.,max);
	gr->GetHistogram("empty")->GetXaxis()->CenterTitle();
	gr->GetHistogram("empty")->GetYaxis()->CenterTitle();
	gr->GetHistogram("empty")->GetZaxis()->CenterTitle();
	gr->Draw("PCOL");
	d->SetFillColor(16);
	
	
#ifdef RENDER
		//Render 3D animation
	const Int_t kUPDATE = 1;
	TSlider *slider = 0;
	
	for (Int_t i = 1; i <= 125; i++){
		TView3D *v = new TView3D();
		v->RotateView(5+i,45+i,d);
			//d->Update();
		
		if(i && (i%kUPDATE)== 0){
			if (i == kUPDATE){
				gr->Draw("PCOL");
				d->Update();
				slider = new TSlider("slider","test",850,-70,856,max);
			}
			if (slider) slider->SetRange(0,Float_t(i)/10000.);
			d->Modified();
			d->Update();
			d->Print("3d.gif+");
		} 
	}
	d->Update();
	d->Print("3d.gif++");
#endif
	
	
		//Saving image
	TImage *img = TImage::Create();
	boost::filesystem::path p(t->Argv(3));
	std::string file = p.parent_path().string();
	file += "_big.png";
	img->FromPad(d);
	img->WriteImage(file.c_str());
		//cleaning
	
	TCanvas *e = new TCanvas("Asymmetry","Asymmetry",10,10,1500,800);
	e->Divide(2,1);
	TGraph *asy_plot = new TGraph(argc-1, argc_ary, asymmety_ary);
	e->cd(1);
	asy_plot->SetTitle("Asymmetry");
	asy_plot->GetHistogram()->GetXaxis()->SetTitle("# Meassurement");
	asy_plot->GetHistogram()->GetYaxis()->SetTitle("Asymmetry");
	asy_plot->GetHistogram()->GetXaxis()->SetRange(1, argc);
	asy_plot->Draw("A*");
	e->Update();
	e->cd(2);
	
	
	TGraph *center_plot = new TGraph(argc-1 , argc_ary, width_ary);
	center_plot->GetHistogram()->GetXaxis()->SetTitle("# Meassurement");
	center_plot->GetHistogram()->GetYaxis()->SetTitle("Center in nm");
	center_plot->GetHistogram()->GetYaxis()->SetRangeUser(startwl, stopwl);
	center_plot->SetTitle("Center");
	center_plot->Draw("A*");
	e->Update();
		//Saving Images
	TImage *secimg = TImage::Create();
	boost::filesystem::path p2(t->Argv(3));
	file = p2.parent_path().string();
	file += "_asy_cent.png";
	secimg->FromPad(e);
	secimg->WriteImage(file.c_str());
	
	TImage *thrdimg = TImage::Create();
	boost::filesystem::path p3(t->Argv(3));
	file = p3.parent_path().string();
	file += "_allplots.png";
	thrdimg->FromPad(c1);
	thrdimg->WriteImage(file.c_str());
	
		//detecting Gradients
	gradient(asymmety_ary, width_ary,cmp_int, argc-1,c1);
	std::cout << "\n\n\nDone !!\nYou can quit now using CTRL+C \n" ;
	
	if (run == true){
		t->Run();
	}
	std::cout << "With \n" ;
	
	delete[] cmp_int;
	delete[] argc_ary; 
	delete[] cmp_int_root;
	delete[] asymmety_ary;
	delete[] width_ary;
	return 0;
}
开发者ID:wutzi15,项目名称:Laser,代码行数:101,代码来源:graph_main.cpp

示例13: PtrelByFittingPlots

void PtrelByFittingPlots (const char * mfile, const char * mcfile)
{
    char name[256];

    gROOT->SetStyle("Plain");

    TFile * measurement = new TFile(mfile, "READ");
    TFile * mctruth = new TFile(mcfile, "READ");

    TCanvas * c1 = new TCanvas("c1", "PtrelSolver apply to TC");
    TImage *img = TImage::Create();

    c1->Divide(3,2);

    c1->cd(1);
    plot(measurement, "/measurements/measurement_n_pT_ntag_pT_TCL_b", mctruth, "/mctruth/mctruth_n_pT_b_ntag_pT_b_TCL");

    c1->cd(2);
    plot(measurement, "/measurements/measurement_n_pT_ntag_pT_TCM_b", mctruth, "/mctruth/mctruth_n_pT_b_ntag_pT_b_TCM");

    c1->cd(3);
    plot(measurement, "/measurements/measurement_n_pT_ntag_pT_TCT_b", mctruth, "/mctruth/mctruth_n_pT_b_ntag_pT_b_TCT");

    c1->cd(4);
    plot(measurement, "/measurements/measurement_n_eta_ntag_eta_TCL_b", mctruth, "/mctruth/mctruth_n_eta_b_ntag_eta_b_TCL");

    c1->cd(5);
    plot(measurement, "/measurements/measurement_n_eta_ntag_eta_TCM_b", mctruth, "/mctruth/mctruth_n_eta_b_ntag_eta_b_TCM");

    c1->cd(6);
    plot(measurement, "/measurements/measurement_n_eta_ntag_eta_TCT_b", mctruth, "/mctruth/mctruth_n_eta_b_ntag_eta_b_TCT");

    sprintf(name, "%s.TC.png", mfile);
    img->FromPad(c1);
    img->WriteImage(name);

    TCanvas * c2 = new TCanvas("c2", "PtrelSolver apply to JP");

    c2->Divide(3,2);

    c2->cd(1);
    plot(measurement, "/measurements/measurement_n_pT_ntag_pT_JPL_b", mctruth, "/mctruth/mctruth_n_pT_b_ntag_pT_b_JPL");

    c2->cd(2);
    plot(measurement, "/measurements/measurement_n_pT_ntag_pT_JPM_b", mctruth, "/mctruth/mctruth_n_pT_b_ntag_pT_b_JPM");

    c2->cd(3);
    plot(measurement, "/measurements/measurement_n_pT_ntag_pT_JPT_b", mctruth, "/mctruth/mctruth_n_pT_b_ntag_pT_b_JPT");

    c2->cd(4);
    plot(measurement, "/measurements/measurement_n_eta_ntag_eta_JPL_b", mctruth, "/mctruth/mctruth_n_eta_b_ntag_eta_b_JPL");

    c2->cd(5);
    plot(measurement, "/measurements/measurement_n_eta_ntag_eta_JPM_b", mctruth, "/mctruth/mctruth_n_eta_b_ntag_eta_b_JPM");

    c2->cd(6);
    plot(measurement, "/measurements/measurement_n_eta_ntag_eta_JPT_b", mctruth, "/mctruth/mctruth_n_eta_b_ntag_eta_b_JPT");

    sprintf(name, "%s.JP.png", mfile);
    img->FromPad(c2);
    img->WriteImage(name);

    TCanvas * c3 = new TCanvas("c3", "PtrelSolver apply to SV");

    c3->Divide(3,2);

    c3->cd(1);
    plot(measurement, "/measurements/measurement_n_pT_ntag_pT_SVL_b", mctruth, "/mctruth/mctruth_n_pT_b_ntag_pT_b_SVL");

    c3->cd(2);
    plot(measurement, "/measurements/measurement_n_pT_ntag_pT_SVM_b", mctruth, "/mctruth/mctruth_n_pT_b_ntag_pT_b_SVM");

    c3->cd(3);
    plot(measurement, "/measurements/measurement_n_pT_ntag_pT_SVT_b", mctruth, "/mctruth/mctruth_n_pT_b_ntag_pT_b_SVT");

    c3->cd(4);
    plot(measurement, "/measurements/measurement_n_eta_ntag_eta_SVL_b", mctruth, "/mctruth/mctruth_n_eta_b_ntag_eta_b_SVL");

    c3->cd(5);
    plot(measurement, "/measurements/measurement_n_eta_ntag_eta_SVM_b", mctruth, "/mctruth/mctruth_n_eta_b_ntag_eta_b_SVM");

    c3->cd(6);
    plot(measurement, "/measurements/measurement_n_eta_ntag_eta_SVT_b", mctruth, "/mctruth/mctruth_n_eta_b_ntag_eta_b_SVT");

    sprintf(name, "%s.SV.png", mfile);
    img->FromPad(c3);
    img->WriteImage(name);

    TCanvas * c4 = new TCanvas("c4", "PtrelSolver apply to CSV");

    c4->Divide(3,2);

    c4->cd(1);
    plot(measurement, "/measurements/measurement_n_pT_ntag_pT_CSVL_b", mctruth, "/mctruth/mctruth_n_pT_b_ntag_pT_b_CSVL");

    c4->cd(2);
    plot(measurement, "/measurements/measurement_n_pT_ntag_pT_CSVM_b", mctruth, "/mctruth/mctruth_n_pT_b_ntag_pT_b_CSVM");

    c4->cd(3);
    plot(measurement, "/measurements/measurement_n_pT_ntag_pT_CSVT_b", mctruth, "/mctruth/mctruth_n_pT_b_ntag_pT_b_CSVT");
//.........这里部分代码省略.........
开发者ID:jdkeller7,项目名称:UserCode,代码行数:101,代码来源:PtrelByFittingPlots.C

示例14: multiHistoDraw


//.........这里部分代码省略.........
     h4->GetYaxis()->SetTitleSize(0.035);
     h4->GetYaxis()->SetTitleFont(42);
     h4->GetZaxis()->SetLabelFont(42);
     h4->GetZaxis()->SetLabelSize(0.035);
     h4->GetZaxis()->SetTitleSize(0.035);
     h4->GetZaxis()->SetTitleFont(42);
     h4->Draw("sames");

     gPad->Update();
     if(drawSBox){
       st4 = (TPaveStats*)h4->FindObject("stats");
       st4->SetY1NDC(y1-stSpacing-stHeight);
       st4->SetY2NDC(y1-stSpacing);
     }
   }

   TLegend *leg = new TLegend(0.3913858,0.6656347,0.7696629,0.876161,NULL,"brNDC");
   leg->SetBorderSize(1);
   leg->SetLineColor(1);
   leg->SetLineStyle(1);
   leg->SetLineWidth(1);
   leg->SetFillColor(0);
   leg->SetFillStyle(1001);
   //TLegendEntry *entry=leg->AddEntry("NULL","Datasets","h");
   //entry->SetLineColor(1);
   //entry->SetLineStyle(1);
   //entry->SetLineWidth(1);
   //entry->SetMarkerColor(1);
   //entry->SetMarkerStyle(21);
   //entry->SetMarkerSize(1);
   //entry->SetTextFont(42);
   TLegendEntry *entry=leg->AddEntry(desc1,desc1,"lpf");

   ci = TColor::GetColor("#ccccff");
   entry->SetFillColor(ci);
   entry->SetFillStyle(1001);

   ci = TColor::GetColor("#000099");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(2);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(1);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   entry=leg->AddEntry(desc2,desc2,"lpf");

   ci = TColor::GetColor("#ffcccc");
   entry->SetFillColor(ci);
   entry->SetFillStyle(3001);
   entry->SetLineColor(2);
   entry->SetLineStyle(2);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(1);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);

   if(filenum >= 3){
     entry=leg->AddEntry(desc3,desc3,"lpf");

     ci = TColor::GetColor("#ffcccc");
     entry->SetFillColor(ci);
     entry->SetFillStyle(3001);
     entry->SetLineColor(2);
     entry->SetLineStyle(2);
     entry->SetLineWidth(1);
     entry->SetMarkerColor(1);
     entry->SetMarkerStyle(1);
     entry->SetMarkerSize(1);
     entry->SetTextFont(42);
   }

   if(filenum >=4){
     entry=leg->AddEntry(desc4,desc4,"lpf");

     ci = TColor::GetColor("#ffcccc");
     entry->SetFillColor(ci);
     entry->SetFillStyle(3001);
     entry->SetLineColor(2);
     entry->SetLineStyle(2);
     entry->SetLineWidth(1);
     entry->SetMarkerColor(1);
     entry->SetMarkerStyle(1);
     entry->SetMarkerSize(1);
     entry->SetTextFont(42);
   }

   leg->Draw();
   c->Modified();
   c->cd();
   c->SetSelected(c);

   TImage *img = TImage::Create();

   img->FromPad(c);
   img->WriteImage(outfile);


}
开发者ID:BaylorCMS,项目名称:HcalPromptAnalysis,代码行数:101,代码来源:multiHistoDraw.C


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