终端命令在程序运行后自动打开图形
Terminal command to auto open Figures after program run
- 注意:这是我第一次发帖,对C++编程语言很陌生,所以请耐心等待。
- 目标: 查找要包含在程序运行后自动打开.png文件(例如:图/pure_comb_4_fits_100logy.png(的宏中的终端命令 OR。
- 实际结果:终端生成以下消息信息:文件图形/pure_comb_2_fits_100logy.png已创建,然后我需要手动输入打开的数字/pure_comb_2_fits_100logy.png以查看文件。
- 期望/预期:希望代码自动打开,而无需手动输入终端。如果解决方案是将更多代码添加到 C 文件中,或者只是将语法输入到终端命令中(首选(,则没关系。
-
代码块:
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; }
假设你运行代码
root drawpc_4.C
,我认为您应该考虑运行它
root -l -b -q drawpc_4.C; open Figures/pure_comb_2_fits_100logy.png
相反。这将在执行完drawpc_4.C
后立即打开您的png
文件。
相关文章:
- 从命令行c++发送文本文件名
- 如何使用 < 和 > 命令获取 c++ 中的输入和输出?
- 为cl.exe(Visual Studio代码)指定命令行C++版本
- 如何在OMNET++中指定与命令行参数组合的输出文件名
- C++图形类指针混淆
- 使用QProcess执行命令,并将结果存储在QStringList中
- 数组长度,为什么从命令行获取时不能使用它?
- 我的代码中有错误吗?使用BGI图形的C++代码对我不起作用
- 如何在内核C++中使用1920x1080x16M图形或类似的16M颜色?(VGA)
- 如果用户输入无效,如何使用字符串变量-C++重复输入命令
- clang整洁10忽略了我的NOLINT命令
- 在子目录中使用target_sources()命令时用于单元测试(qtest)的项目结构
- 如何处理linux终端中带有负号(-)的C++中的命令行参数
- VS Code "command":"make"与终端窗口中的命令行"make"不同
- 使用VS Code和CMake Tools运行自定义命令
- 这是实现图形的坏方法吗
- 终端命令在程序运行后自动打开图形
- 是否可以通过图形用户界面 (GUI) 与 Linux 命令行界面 (CLI) 进行交互
- Programm 在图形外壳中的工作速度比在命令外壳中更快
- 我试图打开一个gnuplot通过命令行使用c++和编译图形