このマニュアルに登場する全てのサンプルは標準の Fortran-77 言語で書かれている。PGPLOT 自体も大部分、標準の Fortran-77 言語で書かれている。
pgplot を使う時に Fortran 言語でプログラムを書かねばならない訳ではない。基本的には Fortran でも良いし、C 言語でも構わない。ただし、C 言語でpgplot を使う場合は、若干の注意点があるらしい。(詳しくは Appendix C を参照)
第2章では、最低限必要な pgplot のサブルーチンを使ってグラフを描く方法を紹介するとともに、それぞれのサブルーチンの役割について説明する。したがって第2章を読めば、pgplot を使った基本的な作図プログラムを自分で書くことができるようになる(ハズ)。
個々のサブルーチンについて詳しい説明は、付録A を参照されたい。
第3章〜第5章では、pgplot の基本的な要素について紹介する。第3章では、ページ上のグラフの配置やスケーリング(縮尺)について説明する。第4章では、pgplot の
この他に、本マニュアルには7つの付録が付いている。付録Aは、pgplot の総てのサブルーチンのリストとそれらについての詳細な説明書である。付録B には、グラフに注釈などを付ける際に用いることが出来る pgplot の文字や記号の一覧を示してある。Appendix C は、C 言語のプログラムで pgplot のサブルーチンを呼び出す方法についてまとめてある。Appendix D には、pgplot でサポートされているデバイスの詳細が書いてある。Appendix E は、pgplot を拡張して元々サポートされていない新たなデバイスを利用できるようにするための手引きである。Appendix F では pgplot のインストール方法を示し、Appendix G には pgplot を新しいOSに組み込むための幾つかのヒントが書かれている。
なお、この日本語版では、元々の pgplot の英語版マニュアルのうち、地球物理学実験を履修している学生諸君にとって必要と思われる範囲のみを日本語に訳してある。したがって、英語の部分は読まなくても、概ね使用には差し支えない。 また、皆さんのプログラミングの際の参考となるよう、簡単な説明付きのサンプルプログラム集を用意した。あわせて利用されたい。
たとえば今、honyarara.f という名前の作図プログラムを作ったとして、これを実行させるには、以下のようなコマンドを実行する(赤字が、実際に打ち込む部分。[CR}
は、リターン(Enter)キーを押すことを意味する)。
> pgf honyarara [CR]
すると、文法エラーなどが無ければ、同じディレクトリ内に ".f" の無い実行形式のプログラム "honyarara" が出来る。次に、これを実行するためには、
> honyarara [CR]
と打ち込む。すると、出力デバイスをプログラム内で指定していない限り(特に意図がなければ指定しない方が便利。詳しくは pgopen や pgbeg の説明を参照)、pgplot から出力デバイスを尋ねられる。画面に表示する場合は、単にリターンキーを押す。学生実験のプリンタ(PostScript プリンタ)で印刷するためには、/ps [CR]
と入力する。すると、前者の場合は直ちに画面に結果が表示され、後者の場合は "pgplot.ps" という名前のPostScriptファイル(本実験ではプリンタ出力用ファイルのこと。略してPSファイルとも呼ぶ)が作られる。
作成したPSファイルをプリンタに出力するためには、
> lpr pgplot.ps [CR]
を実行する。また、一旦PSファイルにした図を再び画面に表示させることも出来る。そのためには、
> gs pgplot.ps [CR]
を実行すれば良い。
なお、ここに記したプログラムのコンパイルの仕方や実行後の操作(印刷、画面表示など)は、あくまで現在の地球物理学実験の計算機環境に限ったものである。
A PGPLOT graphical output device is described by a ``device specification'' that consists of two parts, separated by a slash (/): the device name or file name, and the device type.
/
), enclose the name in
double quotation marks ("
). If the device name is
omitted from the device specification, a default device is used, the
default depending on the device type (see Appendix D). In Unix, device
and file names are case-sensitive.
PGPLOT_TYPE
). The device type is not case-sensitive: you
can use uppercase or lowercase letters, or a mixture of the two.
/XWINDOW
/TEK
(the logged-in terminal)
tta4/TEK
(VMS device _TTA4:
)
"/dev/tty6"/TEK
(Unix device tty6
)
plot.ps/PS
(in the current default directory)
plot.ps/VPS
(the same, but in portrait orientation)
"/scr/tjp/plot.ps"/PS
(in a specified directory)
PGPLOT_
.In UNIX systems, environment variables can be defined using the shell. For the bash, bourne (sh), or korn (ksh) shell, use commands like the following:
PGPLOT_DIR="/usr/local/pgplot"; export PGPLOT_DIRFor the c-shell and tcsh, use
setenv PGPLOT_DIR "/usr/local/pgplot/"Note that the names of PGPLOT environment variables are specified using upper case characters, e.g.
PGPLOT_DIR
, not
pgplot_dir
.
In VMS systems, environment variables are ``logical names'' and can be
defined with the DEFINE
or ASSIGN
command,
e.g.
$ DEFINE PGPLOT_DIR user_disk:[local.pgplot] $ DEASSIGN PGPLOT_DIRThe following environment variables affect all PGPLOT programs:
grfont.dat
and the color-name database is
rgb.txt
. If this variable is undefined, or if the
specified file does not exist in this directory, PGPLOT looks in the
current default directory. e.g.setenv PGPLOT_DIR /usr/local/lib/pgplot/
grfont.dat
in the
directory specified by PGPLOT_DIR. e.g.setenv PGPLOT_FONT /usr/local/pgplot/grfont.dat
rgb.txt
in the
directory specified by PGPLOT_DIR. The color-name database is only
used by programs that call PGSCRN
, or when environment
variable PGPLOT_BACKGROUND or PGPLOT_FOREGROUND is defined. e.g.setenv PGPLOT_RGB /usr/local/pgplot/rgb.txt
PGBEG
(or supplied by the user in
response to the PGPLOT prompt) is a blank string, this device
specification is used, e.g. setenv PGPLOT_DEV /xwin
PGBEG
consists of a file name without a
trailing slash (/) and device type, this device type is
assumed. e.g. setenv PGPLOT_TYPE ps
PGENV
. The characters supplied are
options for PGBOX
(in addition to those assumed by
default by PGENV
, i.e., `BCNST'. Useful options include
`G' to draw a grid, `V' to draw y-axis labels upright, `I' to draw
axis tick marks outside the box instead of inside, `1' or `2' to
change the numeric label style. e.g. setenv PGPLOT_ENVOPT IVG
PGSCRN
with this name as argument
immediately after the graphics device is opened. Color names are
case-insensitive and embedded spaces are ignored. e.g. setenv PGPLOT_FOREGROUND springgreen
PGSCRN
with this name as argument
immediately after the graphics device is opened. On devices without a
color lookup table, changing the background color only affects the
color of elements explicitly drawn in color index 0. To ensure that
the background of the entire view surface changes to the new color, it
is also necessary to call PGERAS
at the start of each
page. e.g. setenv PGPLOT_BACKGROUND slateblue
PGBBUF
is called immediately after opening the
graphics device, and PGEBUF
immediately before closing
it. It will have no effect on programs that already include these
calls. On some devices, buffering output can lead to large
improvements in speed, but enabling buffering may upset
synchronization between graphical output and other program
activity. e.g.setenv PGPLOT_BUFFER yes
setenv PGPLOT_DEBUG yes