# surfaces¶

Draw 2-Dim functions.

Author: Rene Brun
This notebook tutorial was automatically generated with ROOTBOOK-izer from the macro found in the ROOT repository on Sunday, October 02, 2022 at 09:31 AM.

In [1]:
TCanvas *c1 = new TCanvas("c1","Surfaces Drawing Options",200,10,700,900);
TPaveText *title = new TPaveText(.2,0.96,.8,.995);
title->Draw();



We generate a 2-D function

In [2]:
TF2 *f2 = new TF2("f2","x**2 + y**2 - x**3 -8*x*y**4",-1,1.2,-1.5,1.5);
f2->SetContour(48);
f2->SetFillColor(45);


In [3]:
pad1->cd();
f2->Draw("surf4");


Draw this function in pad2 with color mesh option

In [4]:
pad2->cd();
f2->SetLineWidth(1);
f2->SetLineColor(5);
f2->Draw("surf1");


add axis titles. The titles are set on the intermediate histogram used for visualisation. We must force this histogram to be created, then force the redrawing of the two pads

In [5]:
pad2->Update();
f2->GetHistogram()->GetXaxis()->SetTitle("x title");
f2->GetHistogram()->GetYaxis()->SetTitle("y title");
f2->GetHistogram()->GetXaxis()->SetTitleOffset(1.4);
f2->GetHistogram()->GetYaxis()->SetTitleOffset(1.4);

gROOT->GetListOfCanvases()->Draw()