void example(char* name="h_example"){ bool bw=true; TH2D* h_myHisto = new TH2D("h_example","", 61,-0.00107,0.00107,61,-0.00085,0.00085); //Set the bin contents: int binx(1), biny(1); for(int i = -30; i <=30; i++){ biny=1; for(int j = -30; j <=30; j++){ double x = double(i)/10.; double y = double(j)/10.; h_myHisto->SetBinContent(binx,biny,(x*x + y*y )); biny++; } binx++; } //Set up the colours I wish to use: const Int_t ncol = 9; Int_t colors[ncol]; TColor *col; Double_t dg=1.0/(1.0*(Double_t)ncol); Double_t grey=0; for (Int_t i=0; iGetColor(colors[i]); col->SetRGB(grey, grey, grey); grey += dg; } h_myHisto->SetContour(ncol); gStyle->SetPalette(ncol,colors); gStyle->SetOptStat(0); h_myHisto->SetMaximum(9); //X axis labels, etc. h_myHisto->GetXaxis()->SetTitle("X axis \\sigma_{X}"); h_myHisto->GetXaxis()->SetTitleOffset(1.2); h_myHisto->GetXaxis()->SetLabelOffset(0.015); //Y axis labels, etc. h_myHisto->GetYaxis()->SetTitle("Y axis \\sigma_{Y}"); h_myHisto->GetYaxis()->SetTitleOffset(1.2); h_myHisto->GetYaxis()->SetLabelOffset(0.015); h_myHisto->GetXaxis()->SetNdivisions(6, false); h_myHisto->GetYaxis()->SetNdivisions(6, false); TGaxis::SetMaxDigits(4); //Create my canvas: TCanvas* tcan = new TCanvas("myCanvas","myCanvas",500,500); //Make sure it's square: tcan->SetCanvasSize(450,450); tcan->cd(1); //Plot. h_myHisto->Draw("cont4z"); //Save in the eps format. std::string fname = name; fname += ".eps"; tcan->Print(fname.c_str()); }