This file is indexed.

/usr/share/doc/libplplot12/examples/ocaml/x16.ml is in libplplot-dev 5.10.0+dfsg2-0.1ubuntu2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
(* $Id: x16.ml 12639 2013-10-29 00:18:45Z hezekiahcarty $

        plshade demo, using color fill.

        Maurice LeBrun
        IFS, University of Texas at Austin
        20 Mar 1994
*)

open Plplot

let colorbar ?color ?contour values =
  (* Smaller text *)
  plschr 0.0 0.75;
  (* Small ticks on the vertical axis *)
  plsmaj 0.0 0.5;
  plsmin 0.0 0.5;

  let axis =
    [
      `frame0;
      `frame1;
      `vertical_label;
      `unconventional_label;
      `major_ticks;
    ]
  in
  let shade = Plot.shade_colorbar ~custom:true ~axis values in
  let pos = Plot.viewport_pos ~inside:false 0.005 0.0 in
  Plot.plot [
    Plot.colorbar ?color ?contour ~orient:(`top (0.0375, 0.875)) ~label:[`bottom "Magnitude"] ~pos shade;
  ];

  (* Reset text and tick sizes *)
  plschr 0.0 1.0;
  plsmaj 0.0 1.0;
  plsmin 0.0 1.0

let pi = atan 1.0 *. 4.0

(* Fundamental settings.  See notes[] for more info. *)

let ns = 20             (* Default number of shade levels *)
let nx = 35             (* Default number of data points in x *)
let ny = 46             (* Default number of data points in y *)
let exclude = false     (* By default do not plot a page illustrating
                           exclusion. *)

(* polar plot data *)
let perimeterpts = 100

(* Transformation function *)
let mypltr x y tr =
  tr.(0) *. x +. tr.(1) *. y +. tr.(2),
  tr.(3) *. x +. tr.(4) *. y +. tr.(5)

let zdefined x y =
  let z = sqrt (x *. x +. y *. y) in
  if z < 0.4 || z > 0.6 then 1 else 0

(*--------------------------------------------------------------------------*\
 * f2mnmx
 *
 * Returns min & max of input 2d array.
\*--------------------------------------------------------------------------*)
let f2mnmx f =
  let fmax = ref f.(0).(0) in
  let fmin = ref f.(0).(0) in
  for i = 0 to Array.length f - 1 do
    for j = 0 to Array.length f.(i) - 1 do
      fmax := max !fmax f.(i).(j);
      fmin := min !fmin f.(i).(j);
    done
  done;
  !fmin, !fmax

(*--------------------------------------------------------------------------*\
 * Does several shade plots using different coordinate mappings.
\*--------------------------------------------------------------------------*)
let () =
  let fill_width = 2.0 in
  let cont_color = 0 in
  let cont_width = 0.0 in

  (* Parse and process command line arguments *)
  plparseopts Sys.argv [PL_PARSE_FULL];

  (* Load color palettes *)
  plspal0 "cmap0_black_on_white.pal";
  plspal1 "cmap1_gray.pal" true;

  (* Reduce colors in cmap 0 so that cmap 1 is useful on a 16-color display *)
  plscmap0n 3;

  (* Initialize plplot *)
  plinit ();

  (* Set up transformation function *)
  let tr =
    [|
      2.0 /. float_of_int (nx - 1); 0.0; -1.0;
      0.0; 2.0 /. float_of_int (ny-1); -1.0;
    |]
  in

  (* Set up data arrays *)
  let z = Array.make_matrix nx ny 0.0 in
  let w = Array.make_matrix nx ny 0.0 in
  for i = 0 to nx - 1 do
    let x = float_of_int (i - (nx / 2)) /. float_of_int (nx / 2) in
    for j = 0 to ny - 1 do
      let y = float_of_int (j - (ny / 2)) /. float_of_int (ny / 2) -. 1.0 in
      z.(i).(j) <- -. sin (7.0 *. x) *. cos (7.0 *. y) +. x *. x -. y *. y;
      w.(i).(j) <- -. cos (7.0 *. x) *. sin (7.0 *. y) +. 2.0 *. x *. y;
    done
  done;

  let zmin, zmax = f2mnmx z in
  let clevel =
    Array.init ns (
      fun i ->
        zmin +. (zmax -. zmin) *. (float_of_int i +. 0.5) /. float_of_int ns
    )
  in
  let shedge =
    Array.init (ns + 1) (
      fun i ->
        zmin +. (zmax -. zmin) *. float_of_int i /. float_of_int ns
    )
  in

  (* Set up coordinate grids *)
  let xg1 = Array.make nx 0.0 in
  let yg1 = Array.make ny 0.0 in
  let xg2 = Array.make_matrix nx ny 0.0 in
  let yg2 = Array.make_matrix nx ny 0.0 in

  for i = 0 to nx - 1 do
    for j = 0 to ny - 1 do
      let x, y = mypltr (float_of_int i) (float_of_int j) tr in

      let argx = x *. pi /. 2.0 in
      let argy = y *. pi /. 2.0 in
      let distort = 0.4 in

      xg1.(i) <- x +. distort *. cos argx;
      yg1.(j) <- y -. distort *. cos argy;

      xg2.(i).(j) <- x +. distort *. cos argx *. cos argy;
      yg2.(i).(j) <- y -. distort *. cos argx *. cos argy;
    done
  done;

  (* Plot using identity transform *)
  pladv 0;
  plvpor 0.1 0.9 0.1 0.9;
  plwind (-1.0) 1.0 (-1.0) 1.0;

  plpsty 0;

  plshades z (-1.0) 1.0 (-1.0) 1.0 shedge fill_width cont_color cont_width true;

  colorbar shedge;

  plcol0 1;
  plbox "bcnst" 0.0 0 "bcnstv" 0.0 0;
  plcol0 2;
  pllab "distance" "altitude" "Bogon density";

  (* Plot using 1d coordinate transform *)

  (* Load color palettes *)
  plspal0 "cmap0_black_on_white.pal";
  plspal1 "cmap1_blue_yellow.pal" true;

  pladv 0;
  plvpor 0.1 0.9 0.1 0.9;
  plwind (-1.0) 1.0 (-1.0) 1.0;

  plpsty 0;

  plset_pltr (pltr1 xg1 yg1);
  plshades z (-1.0) 1.0 (-1.0) 1.0 shedge fill_width cont_color cont_width true;

  colorbar shedge;

  plcol0 1;
  plbox "bcnst" 0.0 0 "bcnstv" 0.0 0;
  plcol0 2;
  pllab "distance" "altitude" "Bogon density";

  (* Plot using 2d coordinate transform *)

  (* Load color palettes *)
  plspal0 "cmap0_black_on_white.pal";
  plspal1 "cmap1_blue_red.pal" true;

  pladv 0;
  plvpor 0.1 0.9 0.1 0.9;
  plwind (-1.0) 1.0 (-1.0) 1.0;

  plpsty 0;

  plset_pltr (pltr2 xg2 yg2);
  plshades
    z (-1.0) 1.0 (-1.0) 1.0 shedge fill_width cont_color cont_width false;

  colorbar shedge;

  plcol0 1;
  plbox "bcnst" 0.0 0 "bcnstv" 0.0 0;
  plcol0 2;
  plcont w 1 nx 1 ny clevel;

  pllab "distance" "altitude" "Bogon density, with streamlines";

  (* Plot using 2d coordinate transform *)

  (* Load color palettes *)
  plspal0 "";
  plspal1 "" true;

  pladv 0;
  plvpor 0.1 0.9 0.1 0.9;
  plwind (-1.0) 1.0 (-1.0) 1.0;

  plpsty 0;

  plshades z (-1.0) 1.0 (-1.) 1.0 shedge fill_width 2 3.0 false;

  colorbar ~color:(`index 2) ~contour:(`index 2, 3.0) shedge;

  plcol0 1;
  plbox "bcnst" 0.0 0 "bcnstv" 0.0 0;
  plcol0 2;

  pllab "distance" "altitude" "Bogon density";

  (* Note this exclusion API will probably change. *)

  (* Plot using 2d coordinate transform and exclusion*)
  if exclude then (
    pladv 0;
    plvpor 0.1 0.9 0.1 0.9;
    plwind (-1.0) 1.0 (-1.0) 1.0;

    plpsty 0;

    plset_defined zdefined;
    plshades
      z (-1.0) 1.0 (-1.0) 1.0 shedge fill_width cont_color cont_width false;

    colorbar shedge;
    plunset_defined ();

    plcol0 1;
    plbox "bcnst" 0.0 0 "bcnstv" 0.0 0;

    pllab "distance" "altitude" "Bogon density with exclusion";
  );
  (* Example with polar coordinates. *)

  (* Load colour palettes*)
  plspal0 "cmap0_black_on_white.pal";
  plspal1 "cmap1_gray.pal" true;

  pladv 0;
  plvpor 0.1 0.9 0.1 0.9;
  plwind (-1.0) 1.0 (-1.0) 1.0;
  plpsty 0;

  (* Build new coordinate matrices. *)
  for i = 0 to nx - 1 do
    let r = float_of_int i /. float_of_int (nx - 1) in
    for j = 0 to ny - 1 do
      let t = (2.0 *. pi /. (float_of_int ny -. 1.0)) *. float_of_int j in
      xg2.(i).(j) <- r *. cos t;
      yg2.(i).(j) <- r *. sin t;
      z.(i).(j) <- exp (~-.r *. r) *. cos (5.0 *. pi *. r) *. cos (5.0 *. t);
    done
  done;

  (* Need a new shedge to go along with the new data set. *)
  let zmin, zmax = f2mnmx z in

  let shedge =
    Array.init (ns + 1) (
      fun i ->
        zmin +. (zmax -. zmin) *. float_of_int i /. float_of_int ns
    )
  in

  (*  Now we can shade the interior region. *)
  plshades
    z (-1.0) 1.0 (-1.0) 1.0 shedge fill_width cont_color cont_width false;

  colorbar shedge;

  (* Now we can draw the perimeter.  (If do before, shade stuff may overlap.) *)
  let px = Array.make perimeterpts 0.0 in
  let py = Array.make perimeterpts 0.0 in
  for i = 0 to perimeterpts - 1 do
    let t = (2.0 *. pi /. float_of_int (perimeterpts - 1)) *. float_of_int i in
    px.(i) <- cos t;
    py.(i) <- sin t;
  done;
  plcol0 1;
  plline px py;

  (* And label the plot.*)
  plcol0 2;
  pllab "" "" "Tokamak Bogon Instability";

  (* Clean up *)
  plend ();
  ()