物理のかぎしっぽ CO/アクセスログを描いてみよう のバックアップ(No.12)

アクセスログを描いてみよう

gnuplot + unix 環境を使って ここ にあるようなアクセスログを描いてみましょう。

必要環境

Cygwin を入れると gnuplot も入るので、Windows な人は Cygwin を入れて下さい。Cygwin 入手は ここ からどうぞ。 フルインストール(全てのパッケージをインストールする)をお勧めします。

データの入手

日ごとのアクセスログは以下の URL から入手できます。 毎日深夜1時頃には前日分までのデータが更新されています。

http://hooktail.maxwell.jp/data/daycount.log

とりあえずプロット

ダウンロードしたファイルをとりあえずプロットしてみましょう。 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.plt に保存して下さい。そして Cygwin 上から

gnuplot plot01.plt

と実行して下さい。01.eps というファイルができているはずです。 ファイルには以下のようにプロットされています。

01.png

データをプロットすることはできましたが、横軸が変ですね。 これはデータファイルの第一列が「日付」ではなく「数値」として認識されているためです。

x 軸を日付とする

日付として認識させるためには 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
トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
Modified by 物理のかぎプロジェクト PukiWiki 1.4.6 Copyright © 2001-2005 PukiWiki Developers Team. License is GPL.
Based on "PukiWiki" 1.3 by yu-ji Powered by PHP 5.3.29 HTML convert time to 0.008 sec.