* アクセスログを描いてみよう [#l6faed8e] gnuplot + unix 環境を使って [[ここ:http://www12.plala.or.jp/ksp/nocategory/access_day/index.html]] にあるようなアクセスログを描いてみましょう。 ** 必要環境 [#o1cacba3] - gnuplot 4.0 (or later) - unix環境 (Cygwin や Linux などでも可) Cygwin を入れると gnuplot も入るので、Windows な人は Cygwin を入れて下さい。Cygwin 入手は [[ここ:http://cygwin.com/]] からどうぞ。 フルインストール(全てのパッケージをインストールする)をお勧めします。 ** データの入手 [#x71745ac] 日ごとのアクセスログは以下の URL から入手できます。 毎日深夜1時頃には前日分までのデータが更新されています。 http://hooktail.maxwell.jp/data/daycount.log 中身は次のような2つの列からなっています。一列目は日付、二列目はアクセス数です。 20060601 0 20060602 0 20060603 0 20060604 0 20060605 0 20060606 0 20060607 0 20060608 0 20060609 0 20060610 0 20060611 0 20060612 0 20060613 798 20060614 823 20060615 880 20060616 804 20060617 567 20060618 645 20060619 914 20060620 895 20060621 883 20060622 850 20060623 739 20060624 568 (以下略) ** とりあえずプロット [#ed577a06] ダウンロードしたファイルをとりあえずプロットしてみましょう。 ps ファイルに出力したいと思います。 set term postscript eps enhanced colour set xlabel "date" set ylabel "access number" set output "01.eps" plot "daycount.log" using 1:2 notitle with lines lt 1 lw 3 上記をファイル plot01.gp に保存して下さい。そして Cygwin 上から gnuplot plot01.gp と実行して下さい。01.eps というファイルができているはずです。 ファイルには以下のようにプロットされています。 &ref(01.png); データをプロットすることはできましたが、横軸が変ですね。 これはデータファイルの第一列が「日付」ではなく「数値」として認識されているためです。 *** x 軸を日付とする [#x42b5d3f] 日付として認識させるためには plot01.plt を以下のように変更します。 set term postscript eps enhanced colour set xlabel "date" set ylabel "access number" set xdata time set timefmt "%Y%m%d" set format x "%m/%d(%a)" set output "02.eps" plot "daycount.log" using 1:2 notitle with lines lt 1 lw 3 上記をファイルに保存し、Cygwin 上で gnuplot を実行すると 02.eps が生成されます。 gnuplot plot02.gp 02.eps は次のようにプロットされているはずです。 &ref(02.png); 横軸が日付になりましたね。