Debian Codegraph @

examples/std_pgplot.pl

raw symbols SCIP
1 =head1 NAME
2
3 std_pgplot - Examples of PGPLOT routines.
4
5 =head1 SYNOPSIS
6
7 std_pgplot.pl
8
9 =head1 DESCRIPTION
10
11 This file is intended to show the use of PGPLOT routines using the
12 standard interface. See the C<pgplot.pl> file for an object-oriented
13 version of the same (the object-oriented interface is strongly recommended.)
14
15 =cut
16
17 use PDLscip-perl cpan PGPLOT 2.36 PDL/;
18 use PDL::Graphics::PGPLOTscip-perl cpan PGPLOT 2.36 PDL/Graphics/PGPLOT/;
19
20
21 ##
22 ## Test all PGPLOT routines.
23 ##
24 my $random = grandomscip-perl cpan PGPLOT 2.36 main/grandom().(1000);
25 my ($xc, $yc)=histscip-perl cpan PGPLOT 2.36 main/hist(). $random;
26 my $x=zeroesscip-perl cpan PGPLOT 2.36 main/zeroes().(100)->xlinvalsscip-perl cpan PGPLOT 2.36 main/xlinvals().(-5,5);
27 my $y=expscip-perl cpan PGPLOT 2.36 main/exp().(-$x*$x/2);
28
29
30
31 printscip-perl cpan PGPLOT 2.36 main/print(). "First we will test all functions in PGPLOT.\n";
32 printscip-perl cpan PGPLOT 2.36 main/print(). "We also will show most of the options\n";
33 printscip-perl cpan PGPLOT 2.36 main/print(). "After each plot - please press <CR> to proceed - type q<CR> to quit.\n";
34
35 function_to_doscip-perl cpan PGPLOT 2.36 main/function_to_do(). ('dev(), env(), hold(), release(), bin(), line()');
36
37 my $win1 = devscip-perl cpan PGPLOT 2.36 main/dev().('/xw', {Aspect => 1, WindowWidth => 7});
38 envscip-perl cpan PGPLOT 2.36 main/env().(-5, 5, 0, maxscip-perl cpan PGPLOT 2.36 main/max().($yc)*1.1, {Axiscolour => 'Red'});
39 binscip-perl cpan PGPLOT 2.36 main/bin(). $xc, $yc;
40 hold;
41 linescip-perl cpan PGPLOT 2.36 main/line(). $x, $y*maxscip-perl cpan PGPLOT 2.36 main/max().($yc), {LineSty => 'Dashed', Color => 'Blue', LineWidth => 5};
42 release;
43 #close_window($win);
44
45 next_plotscip-perl cpan PGPLOT 2.36 main/next_plot().();
46 function_to_doscip-perl cpan PGPLOT 2.36 main/function_to_do(). ('errb() & points()');
47 my $xd = pdlscip-perl cpan PGPLOT 2.36 main/pdl().(1,3,7,10);
48 my $yd = pdlscip-perl cpan PGPLOT 2.36 main/pdl().(2, 7,5,7);
49 my $dy = sqrtscip-perl cpan PGPLOT 2.36 main/sqrt().($yd**2/12+0.2**2);
50 envscip-perl cpan PGPLOT 2.36 main/env().(0, 15, 0, 10, {Xtitle => 'X-data', Ytitle=>'Y-data',
51 Title => 'An example of errb and points', Font => 'Italic'});
52 pointsscip-perl cpan PGPLOT 2.36 main/points(). $xd, $yd;
53 errbscip-perl cpan PGPLOT 2.36 main/errb(). $xd, $yd, $dy;
54 release;
55
56 next_plotscip-perl cpan PGPLOT 2.36 main/next_plot().();
57 function_to_doscip-perl cpan PGPLOT 2.36 main/function_to_do().('line() poly(), cont(), label_axes() and text()');
58 my $im = rvalsscip-perl cpan PGPLOT 2.36 main/rvals().(100, 100);
59 contscip-perl cpan PGPLOT 2.36 main/cont(). $im, {NCOn => 4};
60 hold;
61 linescip-perl cpan PGPLOT 2.36 main/line(). pdlscip-perl cpan PGPLOT 2.36 main/pdl().(0, 50), pdlscip-perl cpan PGPLOT 2.36 main/pdl().(0, 50), {Color => 'RED'};
62 my $px = pdlscip-perl cpan PGPLOT 2.36 main/pdl().(20, 40, 40, 20, 20);
63 my $py = pdlscip-perl cpan PGPLOT 2.36 main/pdl().(80, 80, 100, 100, 80);
64 polyscip-perl cpan PGPLOT 2.36 main/poly(). $px, $py, {Fill => 3};
65 polyscip-perl cpan PGPLOT 2.36 main/poly(). $px, $py, {Color=>'Red', Fill => 3, Hatch => {Phase => 0.5}};
66 label_axesscip-perl cpan PGPLOT 2.36 main/label_axes().('X-direction', 'Y-direction', 'Title', {Color => 'Yellow'});
67
68 textscip-perl cpan PGPLOT 2.36 main/text(). 'Towards the centre', 24, 25, {Justification => 0.5, Angle=>45,
69 Font => 'Italic'};
70
71
72 next_plotscip-perl cpan PGPLOT 2.36 main/next_plot().();
73 function_to_doscip-perl cpan PGPLOT 2.36 main/function_to_do().('imag(), ctab(), hi2d and several panels');
74
75 $win1= devscip-perl cpan PGPLOT 2.36 main/dev().('/xw', 2, 2, {Aspect => 0.5, CharSize => 2});
76 imagscip-perl cpan PGPLOT 2.36 main/imag(). $im, {Transform => pdlscip-perl cpan PGPLOT 2.36 main/pdl().([0, 0.1, 0, 0, 0, 0.1])};
77 imag1scip-perl cpan PGPLOT 2.36 main/imag1(). $im, {PIX => 1, ITF=>'Sqrt'};
78 ctabscip-perl cpan PGPLOT 2.36 main/ctab().('Fire');
79 imagscip-perl cpan PGPLOT 2.36 main/imag(). $im;
80 hold;
81 contscip-perl cpan PGPLOT 2.36 main/cont(). $im, {Color => 'Yellow'};
82 release;
83 hi2dscip-perl cpan PGPLOT 2.36 main/hi2d(). $im->slicescip-perl cpan PGPLOT 2.36 main/slice().('0:-1:10,0:-1:10');
84
85 next_plotscip-perl cpan PGPLOT 2.36 main/next_plot().();
86 function_to_doscip-perl cpan PGPLOT 2.36 main/function_to_do().('Several plot windows. focus_window(), window_list()');
87
88 close_windowscip-perl cpan PGPLOT 2.36 main/close_window().($win1);
89 $win1 = devscip-perl cpan PGPLOT 2.36 main/dev().('/xw', {Aspect => 1, AxisColour => 'Blue', WindowName => 'First',
90 WindowWidth => 6});
91 my $win2 = devscip-perl cpan PGPLOT 2.36 main/dev().('/xw', {Aspect => 0.618, AxisColour => 'Red',
92 WindowWidth => 6, NewWindow => 1});
93
94 focus_windowscip-perl cpan PGPLOT 2.36 main/focus_window().('First');
95 linescip-perl cpan PGPLOT 2.36 main/line(). $x, $x**2;
96 hold;
97 focus_windowscip-perl cpan PGPLOT 2.36 main/focus_window().($win2);
98 my $ii = whichscip-perl cpan PGPLOT 2.36 main/which().($x>=0);
99 pointsscip-perl cpan PGPLOT 2.36 main/points(). $x->indexscip-perl cpan PGPLOT 2.36 main/index().($ii), sqrtscip-perl cpan PGPLOT 2.36 main/sqrt().($x->indexscip-perl cpan PGPLOT 2.36 main/index().($ii));
100 hold;
101 linescip-perl cpan PGPLOT 2.36 main/line(). $x->indexscip-perl cpan PGPLOT 2.36 main/index().($ii), sqrtscip-perl cpan PGPLOT 2.36 main/sqrt().($x->indexscip-perl cpan PGPLOT 2.36 main/index().($ii)), {Color => 'Red', Linestyle => 'dashed'};
102 release;
103 focus_windowscip-perl cpan PGPLOT 2.36 main/focus_window().($win1);
104 pointsscip-perl cpan PGPLOT 2.36 main/points(). $x, $x**2+$x->grandomscip-perl cpan PGPLOT 2.36 main/grandom().();
105 release;
106
107 my ($nums, $names)=window_listscip-perl cpan PGPLOT 2.36 main/window_list().();
108 printscip-perl cpan PGPLOT 2.36 main/print(). "Window list:\n";
109 for (my $i=0; $i <= $#$nums; $i++) {
110 printscip-perl cpan PGPLOT 2.36 main/print(). " $$nums[$i]: $$names[$i]\n";
111 }
112
113
114 next_plotscip-perl cpan PGPLOT 2.36 main/next_plot().();
115 function_to_doscip-perl cpan PGPLOT 2.36 main/function_to_do().('legend(), cursor()');
116
117 close_windowscip-perl cpan PGPLOT 2.36 main/close_window().($win2);
118
119 legend ['Parabola', 'Scatter points'], -2, 20,
120 {Width => 5, LineStyle => ['Solid', undef], Symbol => [undef, 'Default']};
121
122
123 printscip-perl cpan PGPLOT 2.36 main/print(). "Select a point using the cursor:\n";
124 my ($xp, $yp)=cursorscip-perl cpan PGPLOT 2.36 main/cursor().({Type => 'CrossHair'});
125 printscip-perl cpan PGPLOT 2.36 main/print(). "(X, Y)=($xp, $yp)\n";
126
127 next_plotscip-perl cpan PGPLOT 2.36 main/next_plot().();
128
129 function_to_doscip-perl cpan PGPLOT 2.36 main/function_to_do().('circle(), ellipse(), rectangle() and arrow()');
130
131 devscip-perl cpan PGPLOT 2.36 main/dev().('/xs', {Aspect => 1, WindowWidth => 6});
132 envscip-perl cpan PGPLOT 2.36 main/env().(0, 100, 0,100);
133 circlescip-perl cpan PGPLOT 2.36 main/circle().(50, 50, 10, {Fill => 'Outline'});
134 ellipsescip-perl cpan PGPLOT 2.36 main/ellipse().(40, 20, {MajorAxis => 30, MinorAxis=> 10, Theta => 30*3.14/180, Colour => 'Red'});
135 rectanglescip-perl cpan PGPLOT 2.36 main/rectangle().(70, 70, {XSide => 10, Angle => 45*3.14/180});
136
137 next_plotscip-perl cpan PGPLOT 2.36 main/next_plot().();
138
139 close_windowscip-perl cpan PGPLOT 2.36 main/close_window().($win1);
140
141 $win1 = devscip-perl cpan PGPLOT 2.36 main/dev().('/xw', 2, 2, {Aspect => 1});
142 linescip-perl cpan PGPLOT 2.36 main/line(). $x, $y;
143 binscip-perl cpan PGPLOT 2.36 main/bin(). $xc, $yc, {Panel => 3};
144 envscip-perl cpan PGPLOT 2.36 main/env().(0, 1, 0, 1, {Axis => 'Box'});
145 textscip-perl cpan PGPLOT 2.36 main/text(). "That's all folks!", 0.5, 0.5, {Justification => 0.5, CharSize => 3,
146 Color => 'Yellow'};
147
148 next_plotscip-perl cpan PGPLOT 2.36 main/next_plot().();
149
150
151 sub function_to_doscip-perl cpan PGPLOT 2.36 main/function_to_do(). {
152
153 printscip-perl cpan PGPLOT 2.36 main/print(). "\n**************************\n";
154 printscip-perl cpan PGPLOT 2.36 main/print(). "* $_[0]\n";
155 printscip-perl cpan PGPLOT 2.36 main/print(). "**************************\n\n";
156
157 }
158
159
160 sub next_plotscip-perl cpan PGPLOT 2.36 main/next_plot(). {
161 my $message = shiftscip-perl cpan PGPLOT 2.36 main/shift().;
162
163 $message ||='';
164
165 printscip-perl cpan PGPLOT 2.36 main/print(). $message."\n";
166 my $in = <STDIN>;
167
168 if ($in =~ /^q/i) {
169 exitscip-perl cpan PGPLOT 2.36 main/exit().;
170 }
171
172
173 }