This example demonstrates how arrays of floating point numbers are transferred to SPECTRA. The purpose is to display the data and create a Postscript output file.
#!/usr/bin/perl -w use Spectra; use GQE; # # delete everything # Spectra::delete(); # # create the arrays # my @x_arr = ( 0 .. 100); my @sin_arr = ( 0 .. 100); # # fill the arrays # foreach my $x (@x_arr) { $x = $x/10; } foreach my $y (@sin_arr) { $y = sin($y/10); } # # create the SCAN # $sin = SCAN->create( name => "Sinus", title => "Sinus", x_ptr => \@x_arr, y_ptr => \@sin_arr, colour => "red") or die " Failed to create Sinus "; # # set the viewport: the screen is divided into a 1x2 matrix, # the plot is placed into the position no. 1 # $sin->set( "at" => "(1,2,1)"); # # find window limits and display # Spectra::autoscale(); Spectra::display(); if( Spectra::yesno( "Postscript")) { Post( "/dina4/nocon/print"); }