1
## Copyright (C) 1998, 1999, 2000 Joao Cardoso.
3
## This program is free software; you can redistribute it and/or modify it
4
## under the terms of the GNU General Public License as published by the
5
## Free Software Foundation; either version 2 of the License, or (at your
6
## option) any later version.
8
## This program is distributed in the hope that it will be useful, but
9
## WITHOUT ANY WARRANTY; without even the implied warranty of
10
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
## General Public License for more details.
13
## This file is part of plplot_octave.
14
## It is based on the corresponding demo function of PLplot.
16
## plshade demo, using color fill.
20
## Set up transformation function
22
global nx = 35; ## Default number of data points in x
23
global ny = 46; ## Default number of data points in y
24
global tr = [2/(nx-1); 0.0; -1.0; 0.0; 2/(ny-1); -1.0];
26
function [tx ty] = mypltr( x, y)
28
tx = tr(1) * x + tr(2) * y + tr(3);
29
ty = tr(4) * x + tr(5) * y + tr(6);
34
global tr; global nx; global ny;
35
## Fundamental settings. See notes[] for more info.
37
ns = 20; ## Default number of shade levels
40
"To get smoother color variation, increase ns, nx, and ny. To get faster",
41
"response (especially on a serial link), decrease them. A decent but quick",
42
"test results from ns around 5 and nx, ny around 25."];
45
fill_width = 2; cont_color = 0; cont_width = 0;
46
min_color = 1; min_width = 0; max_color = 0; max_width = 0;
48
## Parse and process command line arguments
50
## plMergeOpts(options, "x16c options", notes);
51
## plparseopts(&argc, argv, PL_PARSE_FULL);
53
## Reduce colors in cmap 0 so that cmap 1 is useful on a 16-color display
55
## Load colour palettes
56
plspal0("cmap0_black_on_white.pal");
57
plspal1("cmap1_gray.pal",1);
66
x = (i - fix(nx / 2)) / fix(nx / 2);
68
y = (j .- fix(ny / 2)) ./ fix(ny / 2) - 1.0;
70
z(i+1,:) = - sin(7.*x) .* cos(7.*y) .+ x*x - y.*y;
71
w(i+1,:) = - cos(7.*x) .* sin(7.*y) .+ 2 .* x .* y;
78
clevel = (zmin .+ (zmax - zmin) .* (i + 0.5) ./ ns)';
80
shedge = zmin + (zmax - zmin) * i / ns;
82
## Set up coordinate grids
86
[x y] = mypltr( i, j);
92
xg1(i+1,:) = x .+ distort .* cos(argx);
93
yg1(i+1,:) = y .- distort .* cos(argy);
95
xg2(i+1,:) = x .+ distort .* cos(argx) .* cos(argy);
96
yg2(i+1,:) = y .- distort .* cos(argx) .* cos(argy);
102
## Plot using identity transform
105
plvpor(0.1, 0.9, 0.1, 0.9);
106
plwind(-1.0, 1.0, -1.0, 1.0);
109
plshades(z, -1., 1., -1., 1.,
111
cont_color, cont_width,
115
plbox("bcnst", 0.0, 0, "bcnstv", 0.0, 0);
118
## plcont(w, 1, nx, 1, ny, clevel, tr);
120
pllab("distance", "altitude", "Bogon density");
122
## Plot using 1d coordinate transform
124
## Load colour palettes
125
plspal0("cmap0_black_on_white.pal");
126
plspal1("cmap1_blue_yellow.pal",1);
127
## Reduce colors in cmap 0 so that cmap 1 is useful on a 16-color display
131
plvpor(0.1, 0.9, 0.1, 0.9);
132
plwind(-1.0, 1.0, -1.0, 1.0);
135
plshades1(z, -1., 1., -1., 1.,
137
cont_color, cont_width,
141
plbox("bcnst", 0.0, 0, "bcnstv", 0.0, 0);
144
## plcont1(w, 1, nx, 1, ny, clevel, xg1, yg1);
146
pllab("distance", "altitude", "Bogon density");
148
## Plot using 2d coordinate transform
150
## Load colour palettes
151
plspal0("cmap0_black_on_white.pal");
152
plspal1("cmap1_blue_red.pal",1);
153
## Reduce colors in cmap 0 so that cmap 1 is useful on a 16-color display
157
plvpor(0.1, 0.9, 0.1, 0.9);
158
plwind(-1.0, 1.0, -1.0, 1.0);
161
plshades2(z, -1., 1., -1., 1.,
163
cont_color, cont_width,
167
plbox("bcnst", 0.0, 0, "bcnstv", 0.0, 0);
169
plcont2(w, 1, nx, 1, ny, clevel, xg2, yg2);
171
pllab("distance", "altitude", "Bogon density, with streamlines");
173
## Plot using 2d coordinate transform
175
## Load colour palettes
178
## Reduce colors in cmap 0 so that cmap 1 is useful on a 16-color display
182
plvpor(0.1, 0.9, 0.1, 0.9);
183
plwind(-1.0, 1.0, -1.0, 1.0);
186
plshades2(z, -1., 1., -1., 1.,
192
plbox("bcnst", 0.0, 0, "bcnstv", 0.0, 0);
194
## plcont2(w, 1, nx, 1, ny, clevel, xg2, yg2);
196
pllab("distance", "altitude", "Bogon density");
198
## Note this exclusion API will probably change.
200
## Plot using 2d coordinate transform and exclusion
201
if (0) ## exclusion not implemented
202
## Load colour palettes
203
plspal0("cmap0_black_on_white.pal");
204
plspal1("cmap1_gray.pal",1);
205
## Reduce colors in cmap 0 so that cmap 1 is useful on a 16-color display
209
plvpor(0.1, 0.9, 0.1, 0.9);
210
plwind(-1.0, 1.0, -1.0, 1.0);
213
plshades2(z, -1., 1., -1., 1.,
215
cont_color, cont_width,
219
plbox("bcnst", 0.0, 0, "bcnstv", 0.0, 0);
220
pllab("distance", "altitude", "Bogon density with exclusion");
223
### Example with polar coordinates.
226
## Load colour palettes
227
plspal0("cmap0_black_on_white.pal");
228
plspal1("cmap1_gray.pal",1);
229
## Reduce colors in cmap 0 so that cmap 1 is useful on a 16-color display
233
plvpor( .1, .9, .1, .9 );
234
plwind( -1., 1., -1., 1. );
238
## Build new coordinate matrices.
244
xg2(i+1,:) = r.*cos(t);
245
yg2(i+1,:) = r.*sin(t);
246
z(i+1,:) = exp(-r.*r).*cos(5*pi*r).*cos(5*t);
249
## Need a new shedge to go along with the new data set.
255
shedge = zmin + (zmax - zmin) * i / ns;
257
## Now we can shade the interior region.
258
plshades2(z, -1, 1, -1, 1,
260
cont_color, cont_width,
263
## Now we can draw the perimeter. (If do before, shade stuff may overlap.)
264
i = 0:PERIMETERPTS-1;
265
t = (2*pi/(PERIMETERPTS-1))*i;
272
## And label the plot.
275
pllab( "", "", "Tokamak Bogon Instability" );