TH2 and TGraphErrors in the same canvas

Hi everyone
I’m trying to show a TH2D and a TGraphErrors together in the same canvas. I have already followed some suggestions from this forum, such as using canvas->Modified(); canvas->Update(); without success.
Any help will be welcome.
The code is copied below.


  Double_t T12=1.39*1e6; 
  Double_t Be_in_sediment_surface=1030*1e6; // atoms of 10Be per gram of young sediment
  Double_t recycling_time =3.5; // in .m.a.
  Double_t extruded_volum_rate=11.5; // km3/km trench/m.a.  10-13
  Double_t subducted_volum_rate=79.5; // km3/km trench/m.a.  78-81
  Double_t Be_in_sediment(Double_t a, Double_t tau){
	Double_t exp1=exp(-log(2)*a*tau/T12);	
  	Double_t exp2=exp(-log(2)*tau/T12);
  	Double_t Be=Be_in_sediment_surface*T12/(log(2)*(1-a)*tau)*(exp1-exp2);
  	return Be;
  void fraction_vs_tau_10Be(double x, double y, double z, double &fraction){
     Double_t Be_in_tephras=x*1e6; // 10Be concentration per gram in 1e6
     Double_t tau=y*1e6; // Sediment height over sedimentation rate, half-life=H/G in m.a.
  	 Float_t a=1-z; // a=x/H, fraction of sediment accreted
     Double_t extruded_flux=extruded_volum_rate;
     Double_t subducted_flux=subducted_volum_rate;
     Double_t decay=exp(-log(2)*recycling_time*1e6/T12);
     Double_t income=subducted_flux*Be_in_sediment(a,tau)*decay;
     Double_t outcome=extruded_flux*Be_in_tephras;
     double f= outcome/income;
     if (f>1) f=1;
     return fraction;
  void f_curves_PA_vs_Recycling(){
     TCanvas* canvas = new TCanvas("canvas","Contour List",0,0,2000,1000);
     Int_t xbins = 100; Double_t xmin=1; Double_t xmax=10;
     Int_t ybins = 100; Double_t ymin=0; Double_t ymax=10;
     Double_t zz = 1; // fraction of subducted sediment
     const char * Title= "f level curves";
     TH2D * histo = new TH2D("histo",Title, xbins, xmin, xmax, ybins, ymin, ymax);
     for (Int_t i = 0; i < xbins; i++) {
        for(Int_t j = 1; j < ybins; j++){
           Double_t value;
           Double_t xx = i*xmax/xbins;  // 10Be per gram of tephras
           Double_t yy = j*ymax/ybins;  // Plate Age's
           fraction_vs_tau_10Be(xx, yy, zz, value); // fraction_vs_tau_10Be
           histo->SetBinContent(i,j, value);
     histo->GetXaxis()->SetTitle("^{10}Be per gram of tephras [10^{6}]");
     histo->GetYaxis()->SetTitle("Plate Age [m.y.]");
     const int npoints = 4;
     double xx[npoints]={2, 4, 6, 8};
     double yy[npoints]={1, 3, 5, 7};
     double exx[npoints]={0.3, 0.2, 0.8, 0.5};
     double eyy[npoints]={0.3, 0.2, 0.8, 0.5};
     TGraphErrors * Measurements = new TGraphErrors(npoints, xx, yy, exx, eyy);

ROOT Version: ROOT 6.24/06

histo->Draw("CONTZ"); // no "4"
Measurements->Draw("P"); // no "A"

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.