ソースコードの所在: /home/kizu/pgplot/samples/pgex05.f
(このプログラムで描ける絵は、こちら)
PROGRAM PGEX05
C----------------------------------------------------------------------
C Demonstration program for the PGPLOT plotting package. This example
C illustrates how to draw a log-log plot.
C PGPLOT subroutines demonstrated:
C PGENV, PGERRY, PGLAB, PGLINE, PGPT, PGSCI.
C----------------------------------------------------------------------
INTEGER RED, GREEN, CYAN
PARAMETER (RED=2)
PARAMETER (GREEN=3)
PARAMETER (CYAN=5)
INTEGER NP
PARAMETER (NP=15)
INTEGER I, PGOPEN
REAL X, YLO(NP), YHI(NP)
REAL FREQ(NP), FLUX(NP), XP(100), YP(100), ERR(NP)
DATA FREQ / 26., 38., 80., 160., 178., 318.,
1 365., 408., 750., 1400., 2695., 2700.,
2 5000., 10695., 14900. /
DATA FLUX / 38.0, 66.4, 89.0, 69.8, 55.9, 37.4,
1 46.8, 42.4, 27.0, 15.8, 9.09, 9.17,
2 5.35, 2.56, 1.73 /
DATA ERR / 6.0, 6.0, 13.0, 9.1, 2.9, 1.4,
1 2.7, 3.0, 0.34, 0.8, 0.2, 0.46,
2 0.15, 0.08, 0.01 /
C
C Call PGOPEN to initiate PGPLOT and open the output device; PGOPEN
C will prompt the user to supply the device name and type. Always
C check the return code from PGOPEN.
C
IF (PGOPEN('?') .LE. 0) STOP
C
C Call PGENV to initialize the viewport and window; the AXIS argument
C is 30 so both axes will be logarithmic. The X-axis (frequency) runs
C from 0.01 to 100 GHz, the Y-axis (flux density) runs from 0.3 to 300
C Jy. Note that it is necessary to specify the logarithms of these
C quantities in the call to PGENV. We request equal scales in x and y
C so that slopes will be correct. Use PGLAB to label the graph.
C
CALL PGSAVE
CALL PGSCI(CYAN)
CALL PGENV(-2.0,2.0,-0.5,2.5,1,30)
CALL PGLAB('Frequency, \gn (GHz)',
1 'Flux Density, S\d\gn\u (Jy)',
2 'PGPLOT Example 5: Log-Log plot')
C
C Draw a fit to the spectrum (don't ask how this was chosen). This
C curve is drawn before the data points, so that the data will write
C over the curve, rather than vice versa.
C
DO 10 I=1,100
X = 1.3 + I*0.03
XP(I) = X-3.0
YP(I) = 5.18 - 1.15*X -7.72*EXP(-X)
10 CONTINUE
CALL PGSCI(RED)
CALL PGLINE(100,XP,YP)
C
C Plot the measured flux densities: here the data are installed with a
C DATA statement; in a more general program, they might be read from a
C file. We first have to take logarithms (the -3.0 converts MHz to GHz).
C
DO 20 I=1,NP
XP(I) = ALOG10(FREQ(I))-3.0
YP(I) = ALOG10(FLUX(I))
20 CONTINUE
CALL PGSCI(GREEN)
CALL PGPT(NP, XP, YP, 17)
C
C Draw +/- 2 sigma error bars: take logs of both limits.
C
DO 30 I=1,NP
YHI(I) = ALOG10(FLUX(I)+2.*ERR(I))
YLO(I) = ALOG10(FLUX(I)-2.*ERR(I))
30 CONTINUE
CALL PGERRY(NP,XP,YLO,YHI,1.0)
CALL PGUNSA
C
C Finally, call PGCLOS to terminate things properly.
C
CALL PGCLOS
C
END