运行C文件后使用终端命令自动打开图形

  • Note: This is my first time posting and very new to C/C++ programming language, so please bear with me.
  • Goal: To find a terminal command, OR, code to be included in the Macro that auto opens the .png files (Ex: Figures/pure_comb_4_fits_100logy.png) after the program is run.
  • Actual Results: Terminal produces the following message Info in : file Figures/pure_comb_2_fits_100logy.png has been created, which I then need to manually enter open Figures/pure_comb_2_fits_100logy.png to view the file.
  • Desired/Expected: Want the code to auto open without the need for manually entering into the terminal. It is alright if the solution is either more code added to the C file, or syntax simply entered into the terminal command (preferred).
  • Code Block:

    void drawpc_4()
    {
    
    TFile* f4 = TFile::Open("OutputFiles/OutFile_BinaryC_20191011-1551_k4.root");
    TProfile* tp1f_4 = (TProfile*)f4->Get("hmult_recursion_0_2");
    
    TCanvas* c1 = new TCanvas("c1","");
    
    tp1f_4->SetMarkerStyle(kFullCircle);
    tp1f_4->SetMarkerColor(kBlack);
    tp1f_4->Draw("ex0p");
    tp1f_4->GetXaxis()->SetRangeUser(0,100);
    tp1f_4->GetXaxis()->SetTitle("Number of particles");
    tp1f_4->GetYaxis()->SetTitle("C_{4}");
    
    c1->SetLogy();
    c1->SetLogx();                                                                                           
    
    TF1* fun1 = new TF1("fun1","[0]/pow(x,3)",3.0,99.9);
    fun1->SetParameter(0,6);                                                                                                                                   
    TF1* fun2 = new TF1("fun2","[0]/((x-1)*(x-2)*(x-3))",3.0,99.9);
    fun2->SetParameter(0,6);                                                                                 
    fun2->SetLineColor(kBlue);
    
    fun1->Draw("same");
    fun2->Draw("same");                                                                                                                  
    
    TLegend* leg = new TLegend(0.2,0.2,0.46,0.4);
    leg->AddEntry(fun2,"combinatoric function","l");
    leg->AddEntry(fun1,"power law function","l");
    leg->Draw();
    
    **c1->Print("Figures/pure_comb_4_fits_100logxlogy.png");**
    c1->SetLogx(0);
    
    TLegend* leg4 = new TLegend(0.48,0.68,0.84,0.88);
    leg4->AddEntry(fun2,"combinatoric function","l");
    leg4->AddEntry(fun1,"power law function","l");
    leg4->Draw();
    
    delete leg;
    c1->Print("Figures/pure_comb_4_fits_100logy.png");
    
    delete c1;
    
    }