コマンドの出力をプロットする方法

コマンドの出力をプロットする方法

GNUPlotを使用してこのコマンドラインの出力をどのようにプロットできますか?チャートスクリプトはどのように見えるべきですか?

ヒストグラムが欲しいです。

wget -O - -o /dev/null http://www.stackoverflow.com/ |
cat | cat | sed "s/</\n</g" |
grep '<\/\{0,1\}[a-zA-Z][a-zA-Z\:\._\-]\{0,\}' |
cut -f 2 -d"<" | cut -f 1 -d">" | cut -f 1 -d" " |
sed "s/\//\\n/g" |
sort | uniq -c |
tail -n +2 |
cut -c5-

ベストアンサー1

これが役に立ちます。ファイルにデータを書き込みます(最初の数字が削除されるためにcut -c5-変更されます)。cut -c4-

wget -O - -o /dev/null http://www.stackoverflow.com/ | cat | sed "s/</\n</g" | grep '<\/\{0,1\}[a-zA-Z][a-zA-Z\:\._\-]\{0,\}' | cut -f 2 -d"<" | cut -f 1 -d">" | cut -f 1 -d" " | sed "s/\//\\n/g" | sort | uniq -c | tail -n +2 | cut -c4- > mydata.txt

作成myplot.dem(ここにいくつかのカスタム初期化を追加し、必要に応じて変更):

set style data histogram
set style fill solid border -1
set log y
set boxwidth 0.9
set term png
set tics out nomirror
set xtics rotate by -45
set output "histogram.png"
plot "mydata.txt" using 1:xticlabels(2)

ついに:

gnuplot myplot.dem

現在のディレクトリに「histogram.png」プロットを作成します。

おすすめ記事