To discuss about scaling for CV plot

void tree(){
auto *c = new TCanvas("c","",500,500);
//c->SetLogy(1);
ifstream in;
ifstream input;
ifstream i;
ifstream p;
ifstream j;
ifstream h;
ifstream k;
ifstream m;
in.open(Form("file 1.txt"));
input.open(Form("file 2.txt"));
i.open(Form("file 3.txt"));
p.open(Form("file 4.txt"));
j.open(Form("file 5.txt"));
h.open(Form("file 6.txt"));
k.open(Form("file 7.txt"));
m.open(Form("file 8.txt"));
Double_t c1,c2;
Double_t cc1,cc2;
Double_t b1,b2;
Double_t a1,a2;
Double_t d1,d2;
Double_t v1,v2;
Double_t x1,x2;
Double_t z1,z2;
Int_t nlines=0;
TGraph* gr = new TGraph ();
TGraph* gr1 = new TGraph ();
TGraph* gr2 = new TGraph ();
TGraph* gr3 = new TGraph ();
TGraph* gr4 = new TGraph ();
TGraph* gr5 = new TGraph ();
TGraph* gr6 = new TGraph ();
TGraph* gr7 = new TGraph ();



while(1){
in>>c2>>c1;
input>>cc2>>cc1;
i>>b2>>b1;
p>>a2>>a1;
j>>d2>>d1;
h>>v2>>v1;
k>>x2>>x1;
m>>z2>>z1;
if(!in.good())break;
gr->SetPoint(nlines,abs(c1),abs(c2));
gr1->SetPoint(nlines,abs(cc1),abs((cc2)));
gr2->SetPoint(nlines,abs(b1),abs(b2));
gr3->SetPoint(nlines,abs(a1),abs(a2));
gr4->SetPoint(nlines,abs(d1),abs(d2));
gr5->SetPoint(nlines,abs(v1),abs(v2));
gr6->SetPoint(nlines,abs(x1),abs(x2));
gr7->SetPoint(nlines,abs(z1),abs(z2));


nlines++;
if (nlines>500)break; 
}

   gr->GetXaxis()->SetTitle("Voltage");
   gr->GetYaxis()->SetTitle("Capicitance");
   gr->GetYaxis()->SetRangeUser(0.00001E-06, 0.04E-06);
//gr->GetYaxis()->SetRangeUser(0E-09, 12E-09);
//gr->GetYaxis()->SetRangeUser(0, 8);

   gr->GetXaxis()->CenterTitle();
   gr->GetYaxis()->CenterTitle();
   gr->SetMarkerColor(4);
   gr->SetMarkerStyle(20);
   gr1->SetMarkerColor(5);
   gr1->SetMarkerStyle(20);
   gr2->SetMarkerColor(20);
   gr2->SetMarkerStyle(20);
   gr3->SetMarkerColor(8);
   gr3->SetMarkerStyle(20);
   gr4->SetMarkerColor(9);
   gr4->SetMarkerStyle(20);
   gr5->SetMarkerColor(1);
   gr5->SetMarkerStyle(20);
   gr6->SetMarkerColor(5);
   gr6->SetMarkerStyle(20);
   gr7->SetMarkerColor(2);
   gr7->SetMarkerStyle(20);


   gr->SetMarkerSize(1);
   gr1->SetMarkerSize(1);
   gr2->SetMarkerSize(1);
   gr3->SetMarkerSize(1);
   gr4->SetMarkerSize(1);
   gr5->SetMarkerSize(1);
   gr6->SetMarkerSize(1);
   gr7->SetMarkerSize(1);
   gr->Draw("AP");
   gr1->Draw("PSAME");
   gr2->Draw("PSAME");
   gr3->Draw("PSAME");
   gr4->Draw("PSAME");
   gr5->Draw("PSAME");
   gr6->Draw("PSAME");
   gr7->Draw("PSAME");
    auto legend = new TLegend(0.1,0.7,0.48,0.9);
   legend->SetHeader("","C"); // option "C" allows to center the header
   legend->AddEntry(gr,"IV(006)","P");
   legend->AddEntry(gr1,"IV(012)","p");
   legend->AddEntry(gr2,"IV(019)","p");
   legend->AddEntry(gr3,"IV(030)","P");
   legend->AddEntry(gr4,"IV(034)","P");
   legend->AddEntry(gr5,"IV(043)","P");
   legend->AddEntry(gr6,"IV(047)","P");
   legend->AddEntry(gr7,"IV(023)","P");
  // legend->AddEntry("gr","Graph with error bars","lep");
   legend->Draw();
in.close();
input.close();
i.close();
p.close();
j.close();
h.close();
k.close();
m.close();

}

hi hope you are fine, I have to plot the graph for CV measurment with strip no on x-axis and capacitance on y-axis from this code i get empty plot suggest me a range that best fit my plot i want range from 0 to 100 on y axis and 0 to 600 on x-axis so what should i do someone modify my code
thankyou!

It’s better to first Add the graphs in a TMultiGraph, so you can see the actual ranges in x and y, and then take it from there.

Welcome to the ROOT forum.
As @dastudillo said a multigraph is better:

void tree(){
   auto *c = new TCanvas("c","",500,500);
   //c->SetLogy(1);
   ifstream in;
   ifstream input;
   ifstream i;
   ifstream p;
   ifstream j;
   ifstream h;
   ifstream k;
   ifstream m;
   in.open(Form("file 1.txt"));
   input.open(Form("file 2.txt"));
   i.open(Form("file 3.txt"));
   p.open(Form("file 4.txt"));
   j.open(Form("file 5.txt"));
   h.open(Form("file 6.txt"));
   k.open(Form("file 7.txt"));
   m.open(Form("file 8.txt"));
   Double_t c1,c2;
   Double_t cc1,cc2;
   Double_t b1,b2;
   Double_t a1,a2;
   Double_t d1,d2;
   Double_t v1,v2;
   Double_t x1,x2;
   Double_t z1,z2;
   Int_t nlines=0;
   auto gr  = new TGraph ();
   auto gr1 = new TGraph ();
   auto gr2 = new TGraph ();
   auto gr3 = new TGraph ();
   auto gr4 = new TGraph ();
   auto gr5 = new TGraph ();
   auto gr6 = new TGraph ();
   auto gr7 = new TGraph ();
   auto mg = new TMultiGraph()
   mg->Add(gr);
   mg->Add(gr1);
   mg->Add(gr2);
   mg->Add(gr3);
   mg->Add(gr4);
   mg->Add(gr5);
   mg->Add(gr6);
   mg->Add(gr7);
   
   while(1) {
      in>>c2>>c1;
      input>>cc2>>cc1;
      i>>b2>>b1;
      p>>a2>>a1;
      j>>d2>>d1;
      h>>v2>>v1;
      k>>x2>>x1;
      m>>z2>>z1;
      if(!in.good())break;
      gr->SetPoint(nlines,abs(c1),abs(c2));
      gr1->SetPoint(nlines,abs(cc1),abs((cc2)));
      gr2->SetPoint(nlines,abs(b1),abs(b2));
      gr3->SetPoint(nlines,abs(a1),abs(a2));
      gr4->SetPoint(nlines,abs(d1),abs(d2));
      gr5->SetPoint(nlines,abs(v1),abs(v2));
      gr6->SetPoint(nlines,abs(x1),abs(x2));
      gr7->SetPoint(nlines,abs(z1),abs(z2));


      nlines++;
      if (nlines>500)break; 
   }

   gr->GetXaxis()->SetTitle("Voltage");
   gr->GetYaxis()->SetTitle("Capicitance");
   gr->GetYaxis()->SetRangeUser(0.00001E-06, 0.04E-06);
   //gr->GetYaxis()->SetRangeUser(0E-09, 12E-09);
   //gr->GetYaxis()->SetRangeUser(0, 8);

   gr->GetXaxis()->CenterTitle();
   gr->GetYaxis()->CenterTitle();
   gr->SetMarkerColor(4);
   gr->SetMarkerStyle(20);
   gr1->SetMarkerColor(5);
   gr1->SetMarkerStyle(20);
   gr2->SetMarkerColor(20);
   gr2->SetMarkerStyle(20);
   gr3->SetMarkerColor(8);
   gr3->SetMarkerStyle(20);
   gr4->SetMarkerColor(9);
   gr4->SetMarkerStyle(20);
   gr5->SetMarkerColor(1);
   gr5->SetMarkerStyle(20);
   gr6->SetMarkerColor(5);
   gr6->SetMarkerStyle(20);
   gr7->SetMarkerColor(2);
   gr7->SetMarkerStyle(20);


   gr->SetMarkerSize(1);
   gr1->SetMarkerSize(1);
   gr2->SetMarkerSize(1);
   gr3->SetMarkerSize(1);
   gr4->SetMarkerSize(1);
   gr5->SetMarkerSize(1);
   gr6->SetMarkerSize(1);
   gr7->SetMarkerSize(1);
   mg->Draw("AP");

    auto legend = new TLegend(0.1,0.7,0.48,0.9);
   legend->SetHeader("","C"); // option "C" allows to center the header
   legend->AddEntry(gr,"IV(006)","P");
   legend->AddEntry(gr1,"IV(012)","p");
   legend->AddEntry(gr2,"IV(019)","p");
   legend->AddEntry(gr3,"IV(030)","P");
   legend->AddEntry(gr4,"IV(034)","P");
   legend->AddEntry(gr5,"IV(043)","P");
   legend->AddEntry(gr6,"IV(047)","P");
   legend->AddEntry(gr7,"IV(023)","P");
   // legend->AddEntry("gr","Graph with error bars","lep");
   legend->Draw();
   in.close();
   input.close();
   i.close();
   p.close();
   j.close();
   h.close();
   k.close();
   m.close();

}

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.