1##  Multi-lingual version of the first page of example 4.
2##
3##  Copyright (C) 2006 Alan Irwin
4##  Copyright (C) 2006 Andrew Ross
5##
6##  Thanks to the following for providing translated strings for this example:
7##  Valery Pipin (Russian)
8##
9##  This file is part of PLplot.
10##
11##  PLplot is free software; you can redistribute it and/or modify
12##  it under the terms of the GNU Library General Public License as published
13##  by the Free Software Foundation; either version 2 of the License, or
14##  (at your option) any later version.
15##
16##  PLplot is distributed in the hope that it will be useful,
17##  but WITHOUT ANY WARRANTY; without even the implied warranty of
18##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19##  GNU Library General Public License for more details.
20##
21##  You should have received a copy of the GNU Library General Public License
22##  along with PLplot; if not, write to the Free Software
23##  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24##
25
26
27##
28## This example designed just for devices (e.g., psttfc and the
29## cairo-related devices) that use the pango and fontconfig libraries. The
30## best choice of glyph is selected by fontconfig and automatically rendered
31## by pango in way that is sensitive to complex text layout (CTL) language
32## issues for each unicode character in this example. Of course, you must
33## have the appropriate TrueType fonts installed to have access to all the
34## required glyphs.
35##
36## Translation instructions: The strings to be translated are given by
37## x_label, y_label, alty_label, title_label, and line_label below.  The
38## encoding used must be UTF-8.
39##
40## The following strings to be translated involve some scientific/mathematical
41## jargon which is now discussed further to help translators.
42##
43## (1) dB is a decibel unit, see http://en.wikipedia.org/wiki/Decibel .
44## (2) degrees is an angular measure, see
45##     http://en.wikipedia.org/wiki/Degree_(angle) .
46## (3) low-pass filter is one that transmits (passes) low frequencies.
47## (4) pole is in the mathematical sense, see
48##     http://en.wikipedia.org/wiki/Pole_(complex_analysis) .  "Single Pole"
49##     means a particular mathematical transformation of the filter function has
50##     a single pole, see
51##     http://ccrma.stanford.edu/~jos/filters/Pole_Zero_Analysis_I.html .
52##     Furthermore, a single-pole filter must have an inverse square decline
53##     (or -20 db/decade). Since the filter plotted here does have that
54##     characteristic, it must by definition be a single-pole filter, see also
55##     http://www-k.ext.ti.com/SRVS/Data/ti/KnowledgeBases/analog/document/faqs/1p.htm
56## (5) decade represents a factor of 10, see
57##     http://en.wikipedia.org/wiki/Decade_(log_scale) .
58##
59
601;
61
62function ix26c
63
64  x_label = [
65	     "Frequency";
66	     "Частота";
67	     ];
68
69  y_label = [
70	     "Amplitude (dB)";
71	     "Амплитуда (dB)";
72	     ];
73
74  alty_label = [
75		"Phase shift (degrees)";
76		"Фазовый сдвиг (градусы)";
77		];
78
79  title_label = [
80		 "Single Pole Low-Pass Filter";
81		 "Однополюсный Низко-Частотный Фильтр";
82		 ];
83
84  line_label = [
85		"-20 dB/decade";
86		"-20 dB/десяток";
87		];
88
89  ## Short rearranged versions of y_label and alty_label.
90  legend_text = {
91		 ["Amplitude"; "Phase shift"],
92		 ["Амплитуда"; "Фазовый сдвиг"]
93		 };
94
95
96  ## Illustration of logarithmic axes, and redefinition of window.
97
98  ## Parse and process command line arguments
99
100  ##    (void) plparseopts(&argc, argv, PL_PARSE_FULL);
101
102  ## Initialize plplot
103
104  plinit;
105  plfont(2);
106
107  ## Make log plots using two different styles.
108
109  for i = 1:size(x_label)(1);
110    plot1(0, deblank(x_label(i,:)), deblank(y_label(i,:)), deblank(alty_label(i,:)), deblank(title_label(i,:)), deblank(line_label(i,:)), legend_text{i});
111  endfor
112
113  plend1;
114endfunction
115
116## Log-linear plot.
117
118function plot1(plottype, x_label, y_label, alty_label, title_label, line_label, legend_text)
119  global PL_LEGEND_LINE PL_LEGEND_SYMBOL PL_LEGEND_BACKGROUND PL_LEGEND_BOUNDING_BOX
120
121  pladv(0);
122
123  ## Set up data for log plot */
124
125  f0 = 1.0;
126  i=0:100;
127  freql = -2.0 + i / 20.0;
128  freq = 10.0 .^ freql;
129  ampl = 20.0 * log10(1.0 ./ sqrt(1.0 + (freq ./ f0).^ 2.));
130  phase = -(180.0 / pi) * atan(freq ./ f0);
131
132  plvpor(0.15, 0.85, 0.1, 0.9);
133  plwind(-2.0, 3.0, -80.0, 0.0);
134
135  ## Try different axis and labelling styles. */
136
137  plcol0(1);
138  switch (plottype)
139
140    case 0
141      plbox("bclnst", 0.0, 0, "bnstv", 0.0, 0);
142
143    case 1
144      plbox("bcfghlnst", 0.0, 0, "bcghnstv", 0.0, 0);
145
146  endswitch
147
148  ## Plot ampl vs freq */
149
150  plcol0(2);
151  plline(freql', ampl');
152  plcol0(2);
153  plptex(1.6, -30.0, 1.0, -20.0, 0.5, line_label);
154
155  ## Put labels on */
156
157  plcol0(1);
158  plmtex("b", 3.2, 0.5, 0.5, x_label);
159  plmtex("t", 2.0, 0.5, 0.5, title_label);
160  plcol0(2);
161  plmtex("l", 5.0, 0.5, 0.5, y_label);
162
163  ## For the gridless case, put phase vs freq on same plot */
164
165  if (plottype == 0)
166    plcol0(1);
167    plwind(-2.0, 3.0, -100.0, 0.0);
168    plbox("", 0.0, 0, "cmstv", 30.0, 3);
169    plcol0(3);
170    plline(freql', phase');
171    plstring(freql', phase', "#(728)");
172    plcol0(3);
173    plmtex("r", 5.0, 0.5, 0.5, alty_label);
174    nlegend = 2;
175  else
176    nlegend = 1
177  endif
178  ## Set up legend arrays with the correct size, type.  In octave this may
179  ## be done by clearing the array (in case it was used before) and then
180  ## writing the last element of the array with a placeholder of the right
181  ## type.  Note that for strings the right placeholder length doesn't
182  ## matter.  Octave keeps track of the longest string in each array and pads
183  ## out all other members with blanks to that length if a subsequent string
184  ## assignment for an array element exceeds that length.
185
186  opt_array = 0;
187  text_colors = 0;
188  text = " ";
189  box_colors = 0;
190  box_patterns = 0;
191  box_scales = 0.;
192  box_line_widths = 0.;
193  line_colors = 0;
194  line_styles = 0;
195  line_widths = 0.;
196  symbol_colors = 0;
197  symbol_scales = 0.;
198  symbol_numbers = 0;
199  symbols = " ";
200
201  opt_array(nlegend,1) = 0;
202  text_colors(nlegend,1) = 0;
203  text(nlegend,1:length(" ")) = " ";
204  box_colors(nlegend,1) = 0;
205  box_patterns(nlegend,1) = 0;
206  box_scales(nlegend,1) = 0.;
207  box_line_widths(nlegend,1) = 0.;
208  line_colors(nlegend,1) = 0;
209  line_styles(nlegend,1) = 0;
210  line_widths(nlegend,1) = 0.;
211  symbol_colors(nlegend,1) = 0;
212  symbol_scales(nlegend,1) = 0.;
213  symbol_numbers(nlegend,1) = 0;
214  symbols(nlegend,1:length(" ")) = " ";
215
216  ## Only specify legend data that are required according to the
217  ## value of opt_array for that entry.
218
219  ## Data for first legend entry.
220  opt_array(1) = PL_LEGEND_LINE;
221  text_colors(1) = 2;
222  text(1,1:length(legend_text(1,:))) = legend_text(1,:);
223  line_colors(1) = 2;
224  line_styles(1) = 1;
225  line_widths(1) = 1.;
226
227  ## Data for second legend entry.
228  if(nlegend > 1)
229    opt_array(2) = bitor(PL_LEGEND_LINE, PL_LEGEND_SYMBOL);
230    text_colors(2) = 3;
231    text(2,1:length(legend_text(1,:))) = legend_text(2,:);
232    line_colors(2) = 3;
233    line_styles(2) = 1;
234    line_widths(2) = 1.;
235    symbol_colors(2) = 3;
236    symbol_scales(2) = 1.;
237    symbol_numbers(2) = 4;
238    symbols(2,1:length("#(728)")) = "#(728)";
239  endif
240
241  plscol0a( 15, 32, 32, 32, 0.70 );
242
243  [legend_width, legend_height] = ...
244      pllegend( bitor(PL_LEGEND_BACKGROUND, PL_LEGEND_BOUNDING_BOX), 0, 0.0, 0.0,
245               0.1, 15, 1, 1, 0, 0, opt_array, 1.0, 1.0, 2.0,
246               1., text_colors, text,
247               box_colors, box_patterns, box_scales, box_line_widths,
248               line_colors, line_styles, line_widths,
249               symbol_colors, symbol_scales, symbol_numbers, symbols );
250
251endfunction
252
253ix26c
254