如何使用 perl 在 gnuplot 中设置多个 timefmt?
我创建了一个使用 Perl 和 gnuplot 绘制图表的工具。这工作正常,但我只是有一个 timefmt 问题。我有许多带有日期的输入数据文件,有些带有时间。因此,我创建了两个单独的工具,仅具有以下区别。
对于我使用的具有时间的输入文件
set timefmt "%H:%M:%S"
set format x "%H:%M"
对于我使用的具有日期的输入文件
set timefmt "%Y-%m-%d"
set format x "%Y-%m"
是否有任何方法可以将不同的 timefmt 放在单个选项中。
I have created a tool to plot graphs using Perl and gnuplot. This is working fine but I just have an issue with the timefmt. I have many input data files with date and some are with time. So, I have created two separate tools with the below difference only.
For the input files which have time I used
set timefmt "%H:%M:%S"
set format x "%H:%M"
For the input files with date I used
set timefmt "%Y-%m-%d"
set format x "%Y-%m"
Is there any way to put the different timefmt at single option.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这将取决于您如何使用脚本。这些是命令行脚本、CGI 脚本还是其他脚本?
如果您的脚本是在命令行上调用的,您可以使用类似 GetOpt::Long 使用命令行选项,并使用脚本中的控制逻辑根据这些选项更改格式。
或者,您可以尝试检测数据文件中的某些内容,这些内容可以为您的脚本提供有关使用哪种格式的线索。
不幸的是,我在你的问题中没有足够的信息来提出这些非常笼统的建议。如果您想了解更多具体信息,请更新您的问题以告诉我们您的脚本是如何调用的,以及您如何读取和处理数据文件。
It will depend on how you use your scripts. Are these command-line scripts, CGI scripts, or something else?
If your scripts are invoked on the command line, you can use a module like GetOpt::Long to work with command-line options, and use control logic in your script to change the format depending on these options.
Alternatively, you could attempt to detect something in the data file which can clue your script as to which format to use.
Unfortunately, I don't have enough information in your question to make more than these very general recommendations. If you'd like more specifics, update your question to tell us how your scripts are invoked, and how you are reading and processing your data files.