Please read tips for efficient and successful posting and posting code
ROOT Version: 6.22/00
Platform: Ubuntu 20.04.1 LTS (WSL2)
Compiler: GNU or GCC
I have created a contour plot of the magnetic flux density of an octupole magnet.
But I want to plot the contour lines and not the field map itself. How can I best do it?
{
const Int_t NCont = 2000;
gStyle->SetNumberContours(NCont);
auto g = new TGraph2D(“Contour_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”);
Double_t r2 = std::pow(0.050, 2.); // radius squared
for (Int_t i = g->GetN() - 1; i >= 0; i–)
if (std::pow(g->GetX()[i], 2.) + std::pow(g->GetY()[i], 2.) > std::pow(0.050, 2.)) g->RemovePoint(i);
g->GetHistogram()->GetXaxis()->SetTitle(“x (m)”);
g->GetHistogram()->GetYaxis()->SetTitle(“y (m)”);
g->SetLineWidth(1);
g->SetLineStyle(1);
g->SetMinimum(0); g->SetMaximum(1.5);
TCanvas *c = new TCanvas(“c”, “c”);
g->Draw(“COLZ”);
c->SetRealAspectRatio();
c->Modified(); c->Update();
TEllipse *e = new TEllipse(0., 0., 0.050); e->SetFillStyle(0); e->Draw();
gPad->Modified(); gPad->Update();
}