1
! $Id: x14f.f90,v 1.5 2006/05/19 23:28:43 airwin Exp $
2
! Demo of multiple stream/window capability
4
! Copyright (C) 2004 Arjen Markus
5
! Copyright (C) 2004 Alan W. Irwin
7
! This file is part of PLplot.
9
! PLplot is free software; you can redistribute it and/or modify
10
! it under the terms of the GNU General Library Public License as
11
! published by the Free Software Foundation; either version 2 of the
12
! License, or (at your option) any later version.
14
! PLplot is distributed in the hope that it will be useful,
15
! but WITHOUT ANY WARRANTY; without even the implied warranty of
16
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
! GNU Library General Public License for more details.
19
! You should have received a copy of the GNU Library General Public
20
! License along with PLplot; if not, write to the Free Software
21
! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23
! Plots several simple functions from other example programs.
25
! This version sends the output of the first 4 plots (one page) to two
26
! independent streams.
32
integer xleng0 , yleng0 , xoff0 , yoff0
33
integer xleng1 , yleng1 , xoff1 , yoff1
36
character*15 geometry_master
37
character*15 geometry_slave
39
real(kind=plflt) x(101), y(101)
40
real(kind=plflt) xs(6), ys(6)
41
real(kind=plflt) xscale, yscale, xoff, yoff
42
common /plotdat/ x, y, xs, ys, xscale, yscale, xoff, yoff
54
geometry_master = '500x410+100+200'
55
geometry_slave = '500x410+650+200'
57
! Process command-line arguments
58
call plparseopts(PL_PARSE_FULL)
62
write(*,*) 'Demo of multiple output streams via the ', &
63
trim(driver), ' driver.'
64
write(*,*) 'Running with the second stream as slave ', &
70
call plsetopt( 'geometry', geometry_master)
80
! Turn off pause to make this a slave (must follow master)
82
call plsetopt( 'geometry', geometry_slave)
83
call plspause(.false.)
87
! Set up the data & plot
98
! Set up the data & plot
104
! Set up the data & plot
109
call plsyax(digmax, 0)
112
! Set up the data & plot
115
yscale = 0.0014_plflt
118
call plsyax(digmax, 0)
122
! The pleop() ensures the eop indicator gets lit.
140
! Back to master to wait for user to advance
145
! Call plend to finish off.
150
!======================================================================
156
real(kind=plflt) x(101), y(101)
157
real(kind=plflt) xs(6), ys(6)
158
real(kind=plflt) xscale, yscale, xoff, yoff, &
159
xmin, xmax, ymin, ymax
161
common /plotdat/ x, y, xs, ys, xscale, yscale, xoff, yoff
164
x(i) = xoff + xscale * dble(i)/60.0_plflt
165
y(i) = yoff + yscale * x(i)**2
174
xs(i) = x((i-1)*10+4)
175
ys(i) = y((i-1)*10+4)
178
! Set up the viewport and window using PLENV. The range in X is
179
! 0.0 to 6.0, and the range in Y is 0.0 to 30.0. The axes are
180
! scaled separately (just = 0), and we just draw a labelled
184
call plenv( xmin, xmax, ymin, ymax, 0, 0 )
186
call pllab( '(x)', '(y)', '#frPLplot Example 1 - y=x#u2' )
188
! Plot the data points
191
call plpoin(xs, ys, 9)
193
! Draw the line through the data
196
call plline(x(:60), y(:60))
200
!======================================================================
205
real(kind=plflt) x(101), y(101)
206
real(kind=plflt) xs(6), ys(6)
207
real(kind=plflt) xscale, yscale, xoff, yoff
209
common /plotdat/ x, y, xs, ys, xscale, yscale, xoff, yoff
211
!======================================================================
213
! Set up the viewport and window using PLENV. The range in X is
214
! -2.0 to 10.0, and the range in Y is -0.4 to 2.0. The axes are
215
! scaled separately (just = 0), and we draw a box with axes
219
call plenv(-2.0_plflt, 10.0_plflt, -0.4_plflt, 1.2_plflt, 0, 1 )
221
call pllab( '(x)', 'sin(x)/x', &
222
'#frPLplot Example 1 - Sinc Function' )
227
x(i) = (i-20.0_plflt)/6.0_plflt
229
if (x(i) .ne. 0.0_plflt) y(i) = sin(x(i)) / x(i)
234
call plline(x(:100), y(:100))
238
!======================================================================
242
! For the final graph we wish to override the default tick intervals,
243
! and so do not use PLENV
245
use plplot, PI => PL_PI
247
real(kind=plflt) x(101), y(101)
248
real(kind=plflt) xs(6), ys(6)
249
real(kind=plflt) xscale, yscale, xoff, yoff
251
common /plotdat/ x, y, xs, ys, xscale, yscale, xoff, yoff
254
! Use standard viewport, and define X range from 0 to 360 degrees,
255
! Y range from -1.2 to 1.2.
258
call plwind( 0.0_plflt, 360.0_plflt, -1.2_plflt, 1.2_plflt )
260
! Draw a box with ticks spaced 60 degrees apart in X, and 0.2 in Y.
263
call plbox( 'bcnst', 60.0_plflt, 2, 'bcnstv', 0.2_plflt, 2 )
265
! Superimpose a dashed line grid, with 1.5 mm marks and spaces. With
266
! only a single mark and space element, we do not need arrays
268
call plstyl( 1, 1500, 1500 )
270
call plbox( 'g', 30.0_plflt, 0, 'g', 0.2_plflt, 0 )
271
call plstyl( 0, 0, 0 )
274
call pllab( 'Angle (degrees)', 'sine', &
275
'#frPLplot Example 1 - Sine function' )
278
x(i) = 3.6_plflt * (i-1)
279
y(i) = sin( x(i) * PI/180.0_plflt )
287
!======================================================================
291
use plplot, PI => PL_PI
294
real(kind=plflt) x0(0:360), y0(0:360)
295
real(kind=plflt) x(0:360), y(0:360), dtr, theta, dx, dy, r
300
x0(i) = cos(dtr * dble (i))
301
y0(i) = sin(dtr * dble (i))
304
! Set up viewport and window, but do not draw box
306
call plenv(-1.3_plflt, 1.3_plflt, -1.3_plflt, 1.3_plflt, 1, -2)
309
x(j) = 0.1_plflt*i*x0(j)
310
y(j) = 0.1_plflt*i*y0(j)
313
! Draw circles for polar grid
323
! Draw radial spokes for polar grid
325
call pljoin(0.0_plflt, 0.0_plflt, dx, dy)
326
write (text,'(i3)') nint(theta)
328
! Write labels for angle
330
text = text(nsp(text):)
331
! Slightly off zero to avoid floating point logic flips at
333
if (dx.ge.-0.00001_plflt) then
334
call plptex(dx, dy, dx, dy, -0.15_plflt, text)
336
call plptex(dx, dy, -dx, -dy, 1.15_plflt, text)
342
r = sin(dtr*dble (5*i))
350
call plmtex('t', 2.0_plflt, 0.5_plflt, 0.5_plflt, &
351
'#frPLplot Example 3 - r(#gh)=sin 5#gh')
353
! Flush the plot at end
358
!======================================================================
360
integer function nsp(text)
363
! Find first non-space character
372
do while(text(nsp:nsp).eq.' ' .and. nsp.lt.l)
377
!======================================================================
381
use plplot, PI => PL_PI
383
integer i, j, nptsx, nptsy, xdim, ydim
384
! xdim and ydim are the absolute static dimensions.
385
! nptsx, and nptsy are the (potentially dynamic) defined area of the 2D
386
! arrays that is actually used.
387
parameter (xdim=99, ydim=100, nptsx=35,nptsy=46)
389
real(kind=plflt) z(xdim, ydim), w(xdim, ydim), clevel(11), &
390
xg1(xdim), yg1(ydim), &
391
xg2(xdim, ydim), yg2(xdim, ydim)
392
real(kind=plflt) xx, yy, argx, argy, distort
393
real(kind=plflt) tr(6)
395
data clevel /-1._plflt, -0.8_plflt, -0.6_plflt, -0.4_plflt, &
397
0._plflt, 0.2_plflt, 0.4_plflt, 0.6_plflt ,0.8_plflt, 1._plflt/
399
tr(1) = 2._plflt/dble(nptsx-1)
403
tr(5) = 2._plflt/dble(nptsy-1)
406
! Calculate the data matrices.
408
xx = dble(i-1-(nptsx/2))/dble (nptsx/2)
410
yy = dble(j-1-(nptsy/2))/dble (nptsy/2) - 1.0_plflt
411
z(i,j) = xx*xx - yy*yy
412
w(i,j) = 2._plflt*xx*yy
416
! Build the 1-d coord arrays.
419
xx = -1._plflt + dble(i-1)*2._plflt/dble(nptsx-1)
420
xg1(i) = xx + distort*cos(0.5_plflt*PI*xx)
424
yy = -1._plflt + dble(j-1)*2._plflt/dble(nptsy-1)
425
yg1(j) = yy - distort*cos(0.5_plflt*PI*yy)
428
! Build the 2-d coord arrays.
430
xx = -1._plflt + dble(i-1)*2._plflt/dble(nptsx-1)
431
argx = 0.5_plflt*PI*xx
433
yy = -1._plflt + dble(j-1)*2._plflt/dble(nptsy-1)
434
argy = 0.5_plflt*PI*yy
435
xg2(i,j) = xx + distort*cos(argx)*cos(argy)
436
yg2(i,j) = yy - distort*cos(argx)*cos(argy)
440
! Plot using identity transform
441
call plenv(-1.0_plflt, 1.0_plflt, -1.0_plflt, 1.0_plflt, 0, 0)
443
call plcont(z,1,nptsx,1,nptsy,clevel,tr)
444
call plstyl(1,1500,1500)
446
call plcont(w,1,nptsx,1,nptsy,clevel,tr)
447
call plstyl(0,1500,1500)
449
call pllab('X Coordinate', 'Y Coordinate', &
450
'Streamlines of flow')