cui編>デモ:ykuno/2019/fig5fig6.pdfcui編のファイルと使い方...
TRANSCRIPT
<CUI編>デモ:
先週、GUIツール(ExcelとWord)で行った作業を、CUIツールで行うとこうなる、というのを見てこう。
* Graphical User Interface マウスでメニュー使用* Command User Interface キーボードによるコマンド入力
CUI編のファイルの中身を確認全部プレーンテキストファイル
• fig5tex.zipをダウンロードし、fig5texを「デスクトップ」に。
• Finderでファイルを確認。4つの.dataファイルは先のと同じ。
• .plotも.texもプレーンテキストファイルなのでcoteditorで開く。
• 「ターミナル」で作業。
(ファイルが在るデスクトップで行う)> open -a coteditor fig5-all-etime-size.plot> open -a coteditor report.tex
ファイル名が長い時は、途中まで打ってtabキーを押したら、その場にあるファイルで該当するファイルの名前が自動補完される。
CUI編のファイルと使い方
• fig5-all-etime-size.plotは、ファイルの中に書かれているgnuplotのコマンド(命令)を、gnuplotコマンドで実行。
• report.texも、texコマンド混じりで書かれた文書を、platexコマンドで整形したのち、 dvipdfmxコマンドで.pdf文書ファイルを生成する。
> gnuplot fig5-all-etime-size.plot
> platex report.tex> platex report.tex> dvipdfmx report> open report.pdf
.plotファイルとetime-size.pdfのグラフset encoding utf8
set terminal pdf
set style line 1 linewidth 4 linecolor rgb "green"set style line 2 linewidth 4 linecolor rgb "red"set style line 3 linewidth 4 linecolor rgb "blue"set style line 4 linewidth 4 linecolor rgb "black"
set output "etime-size.pdf"set xlabel "Size of Social Network"set ylabel "Elapsed Time [sec]"
plot ¥"./cnm-etime-size.data" title "CNM" with lines linestyle 4, ¥"./h2-etime-size.data" title "HE'" with lines linestyle 3, ¥"./h1-etime-size.data" title "HE" with lines linestyle 2, ¥"./hn-etime-size.data" title "HN" with lines linestyle 1
● 赤字は出力ファイルの形式とファイル名● 緑字はグラフを描くための入力データのファイル● 残りの指定はグラフの線や軸タイトル、凡例指定など
← 注意!plotコマンドは1行でかなくてはいけないが、1行で書けないので5行に分割して書いている。分割のため行末はバックスラッシュ(表示が円マークになることが多い)を書く。
cotEditor• 便利なキーボードショートカット(メニューの横に表示)
コマンドキー+s で(メニューを出さなくても)保存
• バックスラッシュ記号(plotコマンドが長くなる時行末に必
要)は、コマンドキーを押しながら¥キー• ¥とバックスラッシュの文字コードについて
コピーはコマンドキー+cカット(削除してコピー)はコマンドキー+cペースト(コピーしたものの貼付)はコマンドキー+v
テーマ2 科学技術文書作成:
.texファイルと、それを元に生成される.pdfファイルを見比べよう
GUI vs CUI ★どっちもできるよう
•GUIでの作業はWYSIWYG、What You See Is What You Get(見たままが得られる)、何かすればその場で結果が見えて分かりやすい。複雑な指定をしようとするとメニューを探し出して使うのが分かりにくくなる傾向。•CUIでの作業は、何をやるにもコマンドを学習しコマンドを指定するだけ。扱うのもテキストファイル。コマンドを実行した結果を想像しながら、バリバリ打つだけなので作業が単純。
*WYSIWYGからの卒業*
• コンピュータの画面にあるものをいじれば何とかなる、という使い方からは卒業して下さい。
• 実際、htmlファイルの編集や、.docxファイルの提出、圧縮ファイルの作成が正しくできなかった人が結構います(メール添付や、OCW-iに提出したものの控えが確認できれば、自分が提出したものを再確認するべきです)。
• どこのどのファイルに対して何を行うのか、自分がやっている事の意味が分かっていないと、そういう失敗をします。
• CUIでは、コマンドでいろんな事をするので、このコマンドを実行したら何が起きるか、自分で予め分かって実行しないといけません。またコマンドの実行結果がすぐに目の前で分かりやすく見えるわけではありません。
テーマ1データの処理と加工
実習A(図5、図6)
テーマ1の実習gnuplotで、グラフ作成
狙い・グラフ資料の作成 ← gnuplot以外のツールでも良い
・実験データファイルの管理 ← !重要
実習のグラフの解説• 実験に用いるデータセット
配布データの元となった研究について
論文執筆に用いたデータについて
実験データの整理と命名について
今日は、実習A:図5と図6の折れ線グラフをやります
共通教材の配布、説明
• https://titechcomp.github.io/y19-il2j/14-dataset.html
• 「こちらからダウンロード」をクリックする。
• theme1-data.zipが解凍され、ダウンロードフォルダにtheme1-dataフォルダがダウンロードされてくる。
• Finderを使って、
• theme1-dataフォルダをダウンロードフォルダから~/Documents/IL2フォルダに移して作業しよう。
• Finderを使ってtheme1-dataフォルダの中身を確認し、ディレクトリ(ファイル)の構造を把握しよう。特に、plot/imagesのフォルダは最初空っぽなことを確認しておこう。
Documents
IL2
Day1
ファイル
フォルダUnix用語では
ディレクトリ
前回作業したファイル
* 実習はthema1-dataフォルダのファイルを直接変更して行うが、失敗してファイルを壊す人が多い。失敗したらまたダウンロードするのは面倒だから、どこかにtheme1-dataのコピー(か圧縮ファイルtheme1-data.zip)を作って失敗した時のやり直しのためのオリジナルのデータも持っておくと良い。
theme1-data
実習:図のように各自のファイルシステムを整備しなさい。
実習:コマンドでtheme1-dataへ移動• Documents/IL2/フォルダにtheme1-dataフォルダを置きました。
• ターミナル窓で、cdコマンドを使って theme1-dataディレクトリへ移動しましょう。
相対パスで一発移動もできる
$ cd Documents/IL2/thema1-data
絶対パスで一発移動もできる
$ cd ~/Documents/IL2/thema1-data
1段ずつ確認しながら移動
$ pwd$ ls$ cd Documents$ pwd$ ls$ cd IL2$ pwd; ls$ cd theme1-data$ pwd; ls
実習:コマンドでtheme-data1の中身を見る
•コマンドを使って、theme1-dataフォルダの中身のフォルダやファイルを見てみましょう。
•コマンドでファイル名を打つとき、長いファイル名を打つの避けるには、tabキーを使います。ファイル名の入力中にtabキーを打つと、その場にあるファイルから適切な候補を選んで自動補完してくれるので、全部打たなくて良くなります。
theme1-data
he1 he2 hn plotcnm
imagesetime-size.dataratio-join.datatime-join-100K.datatime-join-200K.datatime-join-300K.datatime-join-400K.datatime-join-500K.data
etime-size.dataetime-size-M.data
etime-size.dataetime-size-M.data
etime-size.dataEtime-size-M.dataRatio-join-500k.data
最初は空っぽ
.plotを実行してグラフを描いたら、そのグラフの画像ファイルを保存するためのフォルダ
図2のための.plot図3のための.plot図5のための.plot
● カレントディレクトリを cdコマンド で移動
上のディレクトリ(..)に行くのは、 cd ..● dataファイル、.plotファイルの中身を確認する
open –a coteditor ファイル名
Documents
IL2
Day1
ファイル
フォルダUnix用語では
ディレクトリ
前回作業したファイル
theme1-data
実習:カレントディレクトリをtheme1-data/plotに移動しなさい。
ターミナルのカレントディレクトリをtheme1-data/plotに移動しなさい。
plot
images
cnm
★ plot をカレントディレクトリにして作業しよう
• plot フォルダへ移動
• ls で、3つの.plot と imagesフォルダがあるのを見る
• fig5-all-etime-size.plotは、図5のグラフのためのgnuplotスクリプトファイルです
• open –a coteditor fig5-all-etime-size.plot
tabキー長いファイル名を指定するとき全部打つ必要はありません。少し打ってtabキーを押すと、あとは自動補完してくれます。
実習A:図5
$ lsREADME.md he1 hncnm he2 plot
$ cd plot$ ls
fig2-cnm-joins-time-series.plot fig5-all-etime-size.plotfig3-cnm-ratio-joins.plot images
$ open -a coteditor fig5-all-etime-size.plottabキー長いファイル名を指定するとき全部打つ必要はありません。少し打ってtabキーを押すと、あとは自動補完してくれます。
set encoding utf8
set terminal pdf
set style line 1 linewidth 4 dashtype 1 linecolor rgb "black"set style line 2 linewidth 4 dashtype 2 linecolor rgb "black"set style line 3 linewidth 4 dashtype 3 linecolor rgb "black"set style line 4 linewidth 4 dashtype 4 linecolor rgb "black"
set output "images/fig5-all-etime-size.pdf"set xlabel "Size of Social Network"set ylabel "Elapsed Time [sec]"
plot ¥"../cnm/etime-size.data" title "CNM" with lines linestyle 4, ¥"../he2/etime-size.data" title "HE'" with lines linestyle 3, ¥"../he1/etime-size.data" title "HE" with lines linestyle 2, ¥"../hn/etime-size.data" title "HN" with lines linestyle 1
fig5-all-etime-size.plot :gnuplotコマンドで実行したら何が起きるか? 考えてから実行しましょう。
ヒント:これを実行するター
ミナルのカレントディレクトリは、plotディレクトリです。
theme1-data
he1 he2 hn plotcnm
imagesetime-size.dataratio-join.datatime-join-100K.datatime-join-200K.datatime-join-300K.datatime-join-400K.datatime-join-500K.data
etime-size.dataetime-size-M.data
etime-size.dataetime-size-M.data
etime-size.dataEtime-size-M.dataRatio-join-500k.data
最初は空っぽ
図5のための.plot
を実行したら、図5のグラフ画像ファイルができる
図2のための.plot図3のための.plot
図5のための.plot
図5に関係するファイル
図5のグラフのための.dataファイル
図5のための.plotを実行しよう
• fig5-all-etime-size.plotを実行しよう。
• 起きたことの確認
$ gnuplot fig5-all-etime-size.plot
$ lsfig2-cnm-joins-time-series.plot fig5-all-etime-size.plotfig3-cnm-ratio-joins.plot images
$ cd images$ lsfig5-all-etime-size.pdf
$ open fig5-all-etime-size.pdf
Imagesフォルダに行き、ファイルができているのを確認
できている.pdfファイルを開く
set encoding utf8
set terminal pdfset style line 1 linewidth 4 dashtype 1 linecolor rgb "black"set style line 2 linewidth 4 dashtype 2 linecolor rgb "black"set style line 3 linewidth 4 dashtype 3 linecolor rgb "black"set style line 4 linewidth 4 dashtype 4 linecolor rgb "black"
set output "images/fig5-all-etime-size.pdf"set xlabel "Size of Social Network"set ylabel "Elapsed Time [sec]"
plot ¥"../cnm/etime-size.data" title "CNM" with lines linestyle 4, ¥"../he2/etime-size.data" title "HE'" with lines linestyle 3, ¥"../he1/etime-size.data" title "HE" with lines linestyle 2, ¥"../hn/etime-size.data" title "HN" with lines linestyle 1
fig5-all-etime-size.plot を理解しよう
出力先の指定
描画オプションの指定・線の種類・軸ラベルの指定
plotコマンドでグラフの描画を実行・カンマを使って、4組のプロット(線で結ぶ)をする
注意!!!plotコマンドは1行で書くべきだが、長くて途中で分けて書く場合は、行末にバックスラッシュ記号が必要。(改行では実行してしまう)
linewidthとdashtype
• https://titechcomp.github.io/y19-il2j/images/1/gnuplot-parameters.png
注意:imagesフォルダにいる人は、「cd ..」でplotフォルダに戻って次の作業をしましょう。
thema1-data
he1 he2 hn plotcnm
imagesetime-size.dataratio-join.datatime-join-100K.datatime-join-200K.datatime-join-300K.datatime-join-400K.datatime-join-500K.data
etime-size.data
etime-size-M.data
etime-size.data
etime-size-M.data
etime-size.data
Etime-size-M.dataRatio-join-500k.data
fig5-all-etime-size.pdf(図5)
図2のための.plot図3のための.plot図5のための.plot
図6に関係するファイル
図6のグラフのための.dataファイルは3つ
図6のための.plotは自分で作りましょうfig6-tw-etime-size-M2.plot
図6ができるimages/fig6-tw-etime-size-M.pdf
ヒント:図6のスクリプトファイルfig6-tw-etime-size-M2.plotは、図5の fig5-all-etime-size.plot をコピーして作りかえる。グラフのためのデータファイルと、グラフの出力先のファイルを指定し直す。
ヒント: 図6は、図5のスクリプトを参考にして自分でスクリプトを作成する。
• スクリプトファイルの名前は、 fig6-tw-etime-size-M2.plot
• 出力するグラフのpdfファイルの名前は、images/fig6-tw-etime-size-M.pdf として下さい。
• 図6は図5と同様なので、fig6-tw-etime-size-M2.plot はfig5-all-etime-size.plotをコピーしたものを修正して作ります。
• ファイルのコピーは、cp コマンドで行います。
cp コピー元ファイル コピー先ファイル
cp fig5-all-etime-size.plot fig6-tw-etime-size-M2.plot
今日の提出物は2つ
(1) OCW-iから、図5のグラフ画像ファイルを提出。
(2) OCW-iから、図6のグラフ画像ファイルと、そのグラフを描画するために作成した.plotファイル。2つのファイルを圧縮ファイルにしたものを提出する。
$ cd ..$ lsfig2-cnm-joins-time-series.plot fig5-all-etime-size.plotfig3-cnm-ratio-joins.plot images
$ cp fig5-all-etime-size.plot fig6-tw-etime-size-M2.plot
$ lsfig2-cnm-joins-time-series.plot fig6-tw-etime-size-M2.plotfig3-cnm-ratio-joins.plot imagesfig5-all-etime-size.plot
$ open -a coteditor fig6-tw-etime-size-M2.plot
fig6-tw-etime-size-M2.plotをエディタで修正
• HE’ のデータは、 he2/etime-size-M.data です。
• HEのデータは、 he1/etime-size-M.data です。
• HNのデータは、 hn/etime-size-M.data です。
• グラフの出力するpdfファイルの名前は、images/fig6-tw-etime-size-M.pdf
cotEditorで修正し、保存します。gnuplotコマンドでfig6-tw-etime-size-M2.plotを実行させます。
cotEditor• 便利なキーボードショートカット(メニューの横に表示)
コマンドキー+s で(メニューを出さなくても)保存
• バックスラッシュ記号(plotコマンドが長くなる時行末に必
要)は、コマンドキーを押しながら¥キー• ¥とバックスラッシュの文字コードについて
コピーはコマンドキー+cカット(削除してコピー)はコマンドキー+cペースト(コピーしたものの貼付)はコマンドキー+v
$ cat fig6-tw-etime-size-M2.plot
set encoding utf8
set terminal pdf
set style line 1 linewidth 4 dashtype 1 linecolor rgb "black"set style line 2 linewidth 4 dashtype 2 linecolor rgb "black"set style line 3 linewidth 4 dashtype 3 linecolor rgb "black"set style line 4 linewidth 4 dashtype 4 linecolor rgb "black"
set output "images/fig6-tw-etime-size-M.pdf"set xlabel "Size of Social Network"set ylabel "Elapsed Time [sec]"
plot ¥"../he2/etime-size-M.data" title "HE'" with lines linestyle 3, ¥"../he1/etime-size-M.data" title "HE" with lines linestyle 2, ¥"../hn/etime-size-M.data" title "HN" with lines linestyle 1
$ gnuplot fig6-tw-etime-size-M2.plot
$ cd images$ ls
fig5-all-etime-size.pdffig6-tw-etime-size-M.pdf
$ open fig6-tw-etime-size-M.pdf
catはファイルの中身をその場で確認するコマンド。