Why the solid line become line of dashes?

__


_the “red line of dashes” in the green square frame on the figure up is plotted by the below codes:

TGraph* gr2=new TGraph("FitData.txt","%lg %lg");  
 gr2->SetLineColor(2);
 gr2->SetLineWidth(10);

mgr1->Add(gr1);
mgr1->Add(gr2);
mgr1->Add(gr3);
 mgr1->Add(gr4);
 mgr1->Draw("ALB");

the line should be solid, why it become “line of dashes”?


Please read tips for efficient and successful posting and posting code

ROOT Version: 6.24/04
Platform: Ubuntu 20.04
Compiler: GCC 9.3.0


It is not dashes. gr2 is the red one. It is drawn before gr3 and gr4. I guess gr3 or/and gr4 are black. They are drawn above gr2 and therefore hiding it for some points. But the code and the picture you posted are not enough to understand exactly what’s going on. We would need a running reproducer.

yes,you are right, here is the all codes:
FillColor.cpp (4.5 KB)

How shauld i realize the figure with the solid line in the green square frame?

Your data files are missing. We cannot run the macro.
What do you mean by “realise the figure with the solid line in the green square frame” ?
You want to zoom it ?

FitData.txt (306.5 KB)
1.2MeV_PulseSpectrum.txt (229.9 KB)
Here is tha data.

i mean how to change the “line of dashes” to line of solid in the green square frame.

I cleaned up your macro:

void FillColor()
{

//ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
//  1.2MeV fission fragment pulse amplitude spectrum
//ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo

   auto c1 = new TCanvas("1.2MeV Spectrum","1.2MeV Spectrum",900,600);
   c1->SetGrid();
   ifstream ifile1("1.2MeV_PulseSpectrum.txt");

   auto mgr1 = new TMultiGraph();

   auto gr1 = new TGraph("1.2MeV_PulseSpectrum.txt","%lg %lg");
   gr1->SetLineColor(1);
   gr1->SetLineWidth(6);

   auto gr2 = new TGraph("FitData.txt","%lg %lg");
   gr2->SetLineColor(2);
   gr2->SetLineWidth(10);

   auto gr3 = new TGraph();
   gr3->SetLineColor(5);
   gr3->SetFillStyle(1001);
   gr3->SetFillColor(5);   double x,y;
   int start1=0;
   int startpoint1=0;

   while (gr1->GetPoint(startpoint1,x,y)!=-1) {
      if (x>=25.) gr3->SetPoint(start1,x,y);
      start1++;
      startpoint1++;
   }

   auto gr4 = new TGraph();
   gr4->SetLineColor(3);
   gr4->SetFillStyle(1001);
   gr4->SetFillColor(3);
   int start2=0;
   int startpoint2=0;
   while (gr2->GetPoint(startpoint2,x,y)!=-1) {
      if(x<25.)gr4->SetPoint(start2,x,y);
      start2++;
      startpoint2++;
   }

   mgr1->Add(gr3,"B");
   mgr1->Add(gr1,"L");
   mgr1->Add(gr4,"B");
   mgr1->Add(gr2,"L");

    mgr1->Draw("A");
    mgr1->GetXaxis()->SetTitle("Channel");
    mgr1->GetXaxis()->CenterTitle();
    mgr1->GetXaxis()->SetTitleOffset(1.2);
    mgr1->GetXaxis()->SetRangeUser(0,300);
    mgr1->GetYaxis()->SetTitle("Counts");
    mgr1->GetYaxis()->CenterTitle();
    mgr1->GetYaxis()->SetTitleOffset(1.2);
    gPad->RedrawAxis("G");

    auto line1 = new TLine(25,300,25,70);
    line1->SetLineColor(2);
    line1->SetLineWidth(3);
    line1->Draw();

    auto arrow1 = new TArrow(25,65,25,60,0.05,"|>");
    arrow1->SetArrowSize(0.01);
    arrow1->SetFillColor(2);
    arrow1->SetFillStyle(0);
    arrow1->SetLineWidth(2);
    arrow1->SetLineColor(2);
    arrow1->Draw();

    auto latex1 = new TLatex(26,200,"25 channels");
    latex1->SetTextSize(0.03);
    latex1->SetTextColor(2);
    latex1->SetTextFont(10);
    latex1->Draw();
}

Thanks!

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