在ROOT的THistPainter类中使用CONTour选项时,如何添加色阶?

When using CONTour options in ROOT's THistPainter class, how to add a colour scale?

本文关键字:何添加 添加 THistPainter ROOT 选项 CONTour      更新时间:2023-10-16

i当前有编码来创建一个来自输入的数据集

的续图
 const int NbinX = 45; 
 const double binXlow = 0.0; 
 const double binXhigh = 2.0;
 const int NbinY = 45; 
 const double binYlow = 0.0; 
 const double binYhigh = 200.0;

 TH2D* hist3 = new TH2D("hist", "hist", NbinX, binXlow, binXhigh, NbinY, binYlow, binYhigh);
// read in your file     
   ifstream fin("data.dat");
     // while loop to read in file  (checks the input is good )
     // (  x-val    y-val   z-val  )
     double x3 =-999.0;  double y3=-999.0;  double z3 = -999.0;
        while(fin.good()) { 
   fin >> x3 >> y3 >> z3;     
    if( !fin.good()) { break;}  
    // must check if good after reading and before using    
       hist3->Fill( x3 , y3 , z3) ;             
    // Note:  here I just did everything in the while loop 
   }
  TCanvas *c3 = new TCanvas("c3", "c3");
  hist->Draw("CONT4")

但是,与我使用的其他颜色图不同,我使用此颜色图具有Z轴高度的颜色尺度。我需要做些什么才能获得cont情节?

要获得带有线条(而不是颜色)的轮廓图,您需要

hist->Draw("CONT1");

hist->Draw("CONT2");

而不是

hist->Draw("CONT4");

有关轮廓图的更多信息,请参阅此信息。