| 1 | use strict; use warnings; |
| 2 | use Test::More; |
| 3 | use Config; |
| 4 | # Stop f77-linking causing spurious undefined symbols (alpha) |
| 5 | $ENV{'PERL_DL_NONLAZY'}=0 if $Config{'osname'} eq "dec_osf"; |
| 6 | require PGPLOT; |
| 7 | |
| 8 | diag <<EOF if $^O =~ /mswin32/i; |
| 9 | NOTE - Win32 only: If /XSERVE doesn't work properly then |
| 10 | try /PNG (assuming libpng.dll is in your path) with one test-file. |
| 11 | Then view the output '.png' file. |
| 12 | EOF |
| 13 | |
| 14 | my $dev = $ENV{PGPLOT_DEV} || '/NULL'; |
| 15 | diag "Using device '$dev' - set env var PGPLOT_DEV to change"; |
| 16 | |
| 17 | $ENV{PGPLOT_XW_WIDTH}=0.3; |
| 18 | |
| 19 | #PGPLOT::set_debugging(1); |
| 20 | PGPLOT::pgbegin(0,$dev,1,1); # Open plot device |
| 21 | |
| 22 | PGPLOT::pgscf(2); # Set character font |
| 23 | PGPLOT::pgslw(4); # Set line width |
| 24 | PGPLOT::pgsch(1.6); # Set character height |
| 25 | |
| 26 | # Define data limits and plot axes |
| 27 | |
| 28 | PGPLOT::pgenv(0,10,-5,5,0,0); |
| 29 | |
| 30 | PGPLOT::pglabel("X","Y","Data"); # Labels |
| 31 | |
| 32 | PGPLOT::pgsci(5); # Change colour |
| 33 | |
| 34 | my ($i, @x, @y) = 0; |
| 35 | while(<DATA>){ |
| 36 | |
| 37 | # Read data in 2 columns from file handle |
| 38 | # and put in two perl arrays |
| 39 | |
| 40 | ($x[$i], $y[$i]) = split(' '); |
| 41 | $i++; |
| 42 | } |
| 43 | |
| 44 | # Plot points - note how perl arrays are passed |
| 45 | |
| 46 | PGPLOT::pgpoint($i,\@x,\@y,17); |
| 47 | PGPLOT::pgend(); # Close plot |
| 48 | |
| 49 | pass; |
| 50 | done_testing; |
| 51 | |
| 52 | __DATA__ |
| 53 | 1 -4.5 |
| 54 | 2 -4 |
| 55 | 3 -3.2 |
| 56 | 4 -2.1 |
| 57 | 5 -1 |
| 58 | 6 0.3 |
| 59 | 7 1.2 |
| 60 | 8 2.4 |
| 61 | 9 2.9 |