我必须在 shell 脚本的帮助下使用 gnuplot
绘制图表。
我已经编写了这段代码,但它不起作用。我想在 html 文件中绘制图表,以便我可以在浏览器中看到该图表。
echo "set term canvas mousing size 500, 500
set output "file_name.html"
plot 'my_file.txt' with lines" | gnuplot
我已将此文件保存在桌面上的 .bash 中。 现在我在终端中写了这个,但它不起作用
sh file_name.bash
请有人帮我解决这个问题。从昨天开始我就完全被这件事困住了。 :-(
最佳答案
有多个错误,
- 您在
echo
中使用双引号,这是行不通的。将其更改为单引号 - 对多个
gnuplot
命令使用分号而不是换行符
所以生成的脚本应该是这样的
echo "set term canvas mousing size 500, 500; set output 'file_name.html'; plot 'my_file.txt' with lines" | gnuplot
或
cat << __EOF | gnuplot
set term canvas mousing size 500, 500
set output "file_name.html"
plot 'my_file.txt' with lines
__EOF
关于shell - 在 Shell 脚本中使用 gnuplot 绘制图形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11260573/