{
const Int_t NRGBs = 5;
const Int_t NCont = 99;
Double_t stops[NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 };
Double_t red[NRGBs] = { 0.00, 0.00, 0.87, 1.00, 0.51 };
Double_t green[NRGBs] = { 0.00, 0.81, 1.00, 0.20, 0.00 };
Double_t blue[NRGBs] = { 0.51, 1.00, 0.12, 0.00, 0.00 };
TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
gStyle->SetNumberContours(NCont);
//
TGraph2D *g = new TGraph2D("Test_data.txt", "%lg %lg %lg");
g->SetNpx(200);
g->SetNpy(200);
g->SetTitle("Contour plot of the magnetic flux density (T) in the x-y plane");
g->GetHistogram()->SetXTitle(" x [m]");
g->GetHistogram()->GetXaxis()->CenterTitle(kTRUE);
g->GetHistogram()->GetXaxis()->SetTitleOffset(1.1);
g->GetHistogram()->GetXaxis()->SetTitleSize(0.032);
g->GetHistogram()->GetXaxis()->SetLabelSize(0.032);
g->GetHistogram()->SetYTitle(" y [m]");
g->GetHistogram()->GetYaxis()->CenterTitle(kTRUE);
g->GetHistogram()->GetYaxis()->SetTitleOffset(1.3);
g->GetHistogram()->GetYaxis()->SetTitleSize(0.032);
g->GetHistogram()->GetYaxis()->SetLabelSize(0.032);
g->GetHistogram()->GetZaxis()->SetLabelSize(0.032);
g->Draw("colz");
gPad->GetCanvas()->SetRealAspectRatio();
gPad->Modified(); gPad->Update();
//
TH2 *h = (TH2*)g->GetHistogram()->Clone();
h->SetLineColor(kWhite);
h->SetLineWidth(1);
h->SetLineStyle(1);
Double_t dl = 0.05;
Double_t lmin = dl * Int_t(h->GetMinimum() / dl);
#if 1 /* 0 or 1 */
Int_t nlevels = 11;
#else /* 0 or 1 */
Double_t lmax = 1.2;
if (lmax <= lmin) lmax = lmin + 2 * dl;// just a precaution
Int_t nlevels = 1 + Int_t((lmax - lmin) / dl + 0.5);
#endif /* 0 or 1 */
Double_t *levels = new Double_t[nlevels];
for (int i = 0; i < nlevels; i++) levels[i] = lmin + i * dl;
h->SetContour(nlevels, levels);
delete [] levels; // no longer needed
h->Draw("cont3 same");
#if 1 /* 0 or 1 */
TEllipse *e = new TEllipse(0., 0., 0.05); e->SetFillStyle(0); e->Draw();
#endif /* 0 or 1 */
gPad->Modified(); gPad->Update();
}