1. 目的 - テキストファイル内の数値データを種々の方法でグラフ化できるようになる 2. GNUPLOT (ver 4.6) を用いたデータの描画 0) GNUPLOT 4.6 マニュアル(日本語): http://www.gnuplot.info/docs_4.6/gnuplot-ja.pdf 1) 起動法: コマンド gnuplot (Windows では wgnuplot コマンドも利用可能) - 第12回授業内容も参照のこと 2) データの入ったテキストファイル(データファイル)の作成 - Web ページ上のデータをファイルに保存 (sample_a.txt) - コマンドプロンプトとエディタ(メモ帳: コマンド名 notepad)によるファイル (sample_score.txt) 作成(1行目の列ラベルを含めない) 3) 数値のみからなるデータファイルのプロット - データファイルが存在するディレクトリ(フォルダ)の確認 - カレントディレクトリの確認: pwd - データの描画: plot "ファイル名" - 描画スタイル: plot コマンドの with オプション - 諸設定の変更: set コマンド 4) 数値以外を含んだ複数列データのプロット - コメント: # - plot コマンドにおける描画列等の選択: using オプション,描画列指定,定数列 ( ) gnuplot> pwd gnuplot> plot "sample_score.txt" using 2:3 gnuplot> plot "sample_score.txt" using (1):2 with boxplot gnuplot> plot "sample_score.txt" using (1):2, "" using (2):3, "" using (3):4 gnuplot> set style data boxplot gnuplot> set key off gnuplot> set yrange [0:100] gnuplot> set xtics("数学" 1, "英語" 2, "国語" 3) gnuplot> set ylabel "得点" gnuplot> plot "sample_score.txt" using (1):2, "" using (2):3, "" using (3):4 5) 命令の保存と読み込み: save, load コマンド - gnuplot> save "sample_score.plt" 6) 各種デモファイル ("c:\program files (x86)\gnuplot\demo") - gnuplot> load "c:\\program files (x86)\\gnuplot\\demo\\all.dem" 3. R を用いてグラフを作成してみる 1) R の起動とグラフィックス・デモの表示: demo(graphics) 2) R の終了方法: q() 3) カレントディレクトリの確認と変更 getwd() setwd("current_directory_name") 4) データファイルの読み込みと箱ひげ図の描画 (sample_score.txt の一行目に科目名を記入してから) > a <- read.table("sample_score.txt", header=TRUE, row.names=1) > a > summary(a) > boxplot(a) > boxplot(a, ylab="Score", ylim=c(0,100)) 4. 練習問題 資料ページにある gardens.txt には 3 つの場所における10日間のオゾン濃度(ozone concentration) の測定値が pphm (parts per hundred million) 単位で入っているとする。 このデータの箱ひげ図を描きなさい。