File: world.sl

package info (click to toggle)
slxfig 0.2.0~.138-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,196 kB
  • sloc: sh: 3,086; ansic: 598; makefile: 265; php: 6
file content (34 lines) | stat: -rw-r--r-- 856 bytes parent folder | download | duplicates (7)
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
require ("xfig");
require ("rand");

private define f2c (f)
{
   return 5.0/9.0 * (f-32.0);
}

define slsh_main ()
{
   variable w = xfig_plot_new ();
   w.xlabel ("Length [inches]");
   w.x2label ("Length [cm]");
   w.ylabel ("Temperature [F]");
   w.y2label ("Temperature [C]");
   
   % Fake some data
   variable npts = 30;
   variable sigma_l = 0.2;
   variable sigma_t = 20.0;
   variable lengths = [3.0:12.0:#npts] + rand_gauss (sigma_l, npts);
   variable temps = [-200:120:#npts] + rand_gauss (sigma_t, npts);

   w.world1 (lengths, temps);
   w.world2 (2.54*lengths, f2c(temps));
   
   % For fun, plot the data as inches-vs-C, which is world12
   w.plot (lengths, f2c(temps), sigma_l, 5.0/9.0*sigma_t; 
	   world12, sym="x", color="blue");
   
   w.shade_region (6, 8, 0, 1; world10, fillcolor="black", fill=5);
   
   w.render ("world.png");
}