简体   繁体   English

我如何在 shell 脚本上使用 gnuplot 命令

[英]How can i use gnuplot commands on a shell script

Hi guys im trying to build a graphic bar with gnuplot.大家好,我正在尝试用 gnuplot 构建一个图形栏。 I have to put the graphic in a png file and then present it in html page.我必须将图形放入 png 文件中,然后将其呈现在 html 页面中。 Im having problems with using the plot command in my script.我在我的脚本中使用 plot 命令时遇到问题。

If you know to use gnuplot commands in a script, i would aprecciate your help!如果您知道在脚本中使用 gnuplot 命令,我会非常感谢您的帮助!

You can easily use gnuplot commands within an interactive shell, on in a shell script:您可以在 shell 脚本中的交互式 shell 中轻松使用 gnuplot 命令:

echo 'set term pngcairo; set output "file.png"; plot x' | gnuplot

You could also put your commands in file.gnuplot and then execute你也可以把你的命令放在file.gnuplot然后执行

gnuplot file.gnuplot

from within your shell script or interactive shell.从您的 shell 脚本或交互式 shell 中。 If instead of writing to file you just want the graph to pop up using the default gnuplot terminal, you can add -persist :如果您不想写入文件,而只想使用默认的 gnuplot 终端弹出图形,则可以添加-persist

echo 'plot x' | gnuplot -persist

You can also use shell commands inside a gnuplot script or gnuplot interactive session via a system() call, but that's a separate topic.您还可以通过system()调用在 gnuplot 脚本或 gnuplot 交互式 session 中使用 shell 命令,但这是一个单独的主题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM