File: test1.p

package info (click to toggle)
libpgplot-perl 1%3A2.21-6
  • links: PTS, VCS
  • area: contrib
  • in suites: stretch
  • size: 316 kB
  • ctags: 31
  • sloc: perl: 679; ansic: 453; makefile: 7
file content (54 lines) | stat: -rwxr-xr-x 964 bytes parent folder | download | duplicates (11)
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
#!/usr/local/bin/perl  

use PGPLOT;  # Load PGPLOT module

print "\nTesting simple point plot...\n\n";

print "PGPLOT module version $PGPLOT::VERSION\n\n";

pgqinf("VERSION",$val,$len);
print "PGPLOT $val library\n\n";

# "?" will prompt for device

$dev = "?" unless defined $dev; 

pgbegin(0,$dev,1,1);  # Open plot device 

pgscf(2);             # Set character font
pgslw(4);             # Set line width
pgsch(1.6);           # Set character height

# Define data limits and plot axes

pgenv(0,10,-5,5,0,0);    

pglabel("X","Y","Data"); # Labels

pgsci(5);                # Change colour

@x=(); @y=(); $i=0;
while(<DATA>){               

   # Read data in 2 columns from file handle
   # and put in two perl arrays

   ($x[$i], $y[$i]) = split(' ');    
   $i++;
}

# Plot points - note how perl arrays are passed

pgpoint($i,\@x,\@y,17);                           
pgend;    # Close plot

__DATA__
1 -4.5
2 -4
3  -3.2
4 -2.1
5 -1
6 0.3
7 1.2
8 2.4
9 2.9