1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

シェルスクリプト上でgnuplotを動かす

Last updated at Posted at 2021-02-10

#目的
シェルスクリプト上でgnuplotのスクリプトにパスを与えて繰り返し処理をしたい

描画プログラムをgnuplotで書いたが、繰り返し処理やファイル操作をgnuplotのスクリプト上で行うのは面倒なので、シェルスクリプトを用いて、描画部だけgnuplotを用いたい

#参考
大筋はこちらのページを参考にした
http://auewe.hatenablog.com/entry/2013/06/03/012031

#実行
今回はターミナル上で引数として入力データとタイトル名を与える。

Visualization.sh
#!/usr/bin/bash -f
# Visualization.sh
# 第一引数データ
# 第二引数タイトル

dataPath=$1
title=$2
echo "plot ${dataPath} Spectral. title is ${title} ."
echo ${dataPath} | sed -e  "s#/#\\\\#g"
gnuplot << EOF
  set terminal png
  set output '${title}.png'
  set nokey
  plot '${dataPath}' with lines
EOF

追加で加えた処理が以下
cygwin上で動かすため、入力パスは”/”区切りだが、gnuplot上では""で処理されるため、その置換を行った
(参考:https://qiita.com/miriwo/items/8bf37eedf92fc6ea8b77)


echo ${dataPath} | sed -e  "s#/#\\\\#g"

#出力

test.png

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?