【问题标题】:Removing the file paths in the autotitle key labels in gnuplot, leaving just the filename删除 gnuplot 中自动标题键标签中的文件路径,只留下文件名
【发布时间】:2013-10-28 18:47:41
【问题描述】:

根据搜索命令的输出,我在 gnuplot 中使用 for 循环来绘制多个文件。 plot 命令将整个文件名放在键中,包括完整路径。我只想放文件名,删除目录路径。这可能吗?

#!/usr/bin/gnuplot -persist

set terminal pdfcairo enhanced size 10in,7in

wmax_List = "`echo $(ls E0025/4D/Re2000/NS.dat.*[02468]000)`"

plot for [i in wmax_List] i using 1:2 with points title i

在这种情况下,所有文件都在同一个文件夹中。 title i 选项使得 "E0025/4D/Re2000/" 出现在情节键的每一行中。我可以将绘图脚本放在那个文件夹中,但是那里有数千个数据文件(我实际上每 1000 个绘制一个),所以我更喜欢在当前位置执行脚本。

所以,我的问题是,有没有办法从密钥中删除完整路径?我尝试使用 find 而不是 ls 来生成仅包含文件名的字符串列表,但我不知道如何将完整路径 + 字符串放入 plot 命令中。

谢谢

【问题讨论】:

    标签: plot formatting key gnuplot filenames


    【解决方案1】:

    你有不同的可能性:

    dirname = 'E0025/4D/Re2000/'
    wmax_List = system('ls '.dirname.'NS.dat.*[02468]000')
    ind = strlen(dirname)+1
    
    plot for [i in wmax_List] i using 1:2 with points title i[ind:*]
    

    plot for [i in wmax_List] i using 1:2 with points title system('basename '.i)
    

    【讨论】:

    • 谢谢。这正是我一直在寻找的
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-08-18
    • 2012-03-10
    • 1970-01-01
    • 2019-06-26
    • 2021-12-31
    • 1970-01-01
    • 2013-07-02
    相关资源
    最近更新 更多