Double_t transfer_function(Double_t *x, Double_t * /*param*/) { //This function is required to suppress //boxes for empty bins - make them transparent. if (x) return *x > 0 ? 1. : 0.; return 0.; } void DoItThisWay(){ gStyle->SetCanvasPreferGL(kTRUE); gStyle->SetPalette(1); TFile* file = new TFile("file.root","READ"); TH3F* hist = (TH3F*) file->Get("hist"); hist->SetName("hist"); TCanvas* c1 = new TCanvas("c1","3D",600,600); hist->Draw("glcolz"); TFile* file2 = new TFile("file2.root","RECREATE"); hist->Write(); file2->Close(); TFile* file3 = new TFile("file2.root","READ"); TH3F* hist2 = (TH3F*) file3->Get("hist"); hist2->SetName("hist2"); TList * lof = hist2->GetListOfFunctions(); if (!lof) { std::cout<<"List of functions is null\n"; delete hist2; return; } lof->Add(new TF1("TransferFunction", transfer_function, 0., 1000., 0)); TCanvas* c2 = new TCanvas("c2","3D modified",600,600); hist2->Draw("glcolz"); }