* Bug 15884 fixed: bode() layout improved 34/20634/5
Samuel GOUGEON [Sat, 24 Nov 2018 00:34:44 +0000 (01:34 +0100)]
  http://bugzilla.scilab.org/15884

  Comparison without/with this patch (rendering scale 1:1):
     http://bugzilla.scilab.org/attachment.cgi?id=4849

Change-Id: Ida1a668ca93b8ca546583f7b45927af38f62d575

36 files changed:
scilab/CHANGES.md
scilab/modules/cacsd/help/en_US/linear_analysis/freq_domain/bode.xml
scilab/modules/cacsd/help/ja_JP/linear_analysis/freq_domain/bode.xml
scilab/modules/cacsd/macros/bode.sci
scilab/modules/cacsd/macros/formatBodeMagTip.sci
scilab/modules/cacsd/macros/formatBodePhaseTip.sci
scilab/modules/helptools/images/bode_asymp_en_US_1.png
scilab/modules/helptools/images/bode_asymp_en_US_2.png
scilab/modules/helptools/images/bode_asymp_en_US_3.png
scilab/modules/helptools/images/bode_asymp_fr_FR_1.png
scilab/modules/helptools/images/bode_asymp_fr_FR_2.png
scilab/modules/helptools/images/bode_asymp_fr_FR_3.png
scilab/modules/helptools/images/bode_asymp_ja_JP_1.png
scilab/modules/helptools/images/bode_asymp_ja_JP_2.png
scilab/modules/helptools/images/bode_asymp_ja_JP_3.png
scilab/modules/helptools/images/bode_asymp_pt_BR_1.png
scilab/modules/helptools/images/bode_asymp_pt_BR_2.png
scilab/modules/helptools/images/bode_asymp_pt_BR_3.png
scilab/modules/helptools/images/bode_asymp_ru_RU_1.png
scilab/modules/helptools/images/bode_asymp_ru_RU_2.png
scilab/modules/helptools/images/bode_asymp_ru_RU_3.png
scilab/modules/helptools/images/bode_en_US_1.png
scilab/modules/helptools/images/bode_en_US_2.png
scilab/modules/helptools/images/bode_en_US_3.png
scilab/modules/helptools/images/bode_fr_FR_1.png
scilab/modules/helptools/images/bode_fr_FR_2.png
scilab/modules/helptools/images/bode_fr_FR_3.png
scilab/modules/helptools/images/bode_ja_JP_1.png
scilab/modules/helptools/images/bode_ja_JP_2.png
scilab/modules/helptools/images/bode_ja_JP_3.png
scilab/modules/helptools/images/bode_pt_BR_1.png
scilab/modules/helptools/images/bode_pt_BR_2.png
scilab/modules/helptools/images/bode_pt_BR_3.png
scilab/modules/helptools/images/bode_ru_RU_1.png
scilab/modules/helptools/images/bode_ru_RU_2.png
scilab/modules/helptools/images/bode_ru_RU_3.png

index fcc5a79..282e207 100644 (file)
@@ -693,6 +693,7 @@ Known issues
 * [#15878](http://bugzilla.scilab.org/show_bug.cgi?id=15878): `sgrid` and `evans` were broken.
 * [#15880](http://bugzilla.scilab.org/show_bug.cgi?id=15880): `sgrid` needed some improvements: Labeling was sometimes ambiguous ; large circles were not labeled ; data_bounds did not always take the input wn into account ; named and #RRGGBB colors specifications could not be used. `evans` needed some improvements: the block of legends hid data ; asymptotes were too visible.
 * [#15881](http://bugzilla.scilab.org/show_bug.cgi?id=15881): Demos about stems, bars and histograms were spread in several subsections.
+* [#15884](http://bugzilla.scilab.org/show_bug.cgi?id=15884): `bode` frequencies ticking and grid style were poor. With legends, the phase plot was vertically shrunk and some graphical space was lost below it.
 * [#15886](http://bugzilla.scilab.org/show_bug.cgi?id=15886): Display of polynomials was broken.
 * [#15890](http://bugzilla.scilab.org/show_bug.cgi?id=15890): `evstr` sometimes yielded some `+[]` warnings.
 * [#15891](http://bugzilla.scilab.org/show_bug.cgi?id=15891): Help pages of matrix-wise trigonometrical functions deserved a dedicated subsection.
index d3a4b14..03636c8 100644 (file)
@@ -31,7 +31,7 @@
             bode(frq, db, phi)
             bode(frq, repf)
             bode(.., Captions)
-            bode(.., Captions, "rad")
+            bode(.., "rad")
         </synopsis>
     </refsynopsisdiv>
     <refsection>
@@ -98,7 +98,8 @@
             <varlistentry>
                 <term>"rad"</term>
                 <listitem>
-                    <para>converts the frequency from Hz into rad/s (multiplies by 2π),
+                    <para>as last optional argument: displays the Bode plot versus Angular frequencies
+                      in rad/s, instead of versus frequencies in Hz.
                     </para>
                 </listitem>
             </varlistentry>
index 42560eb..14e6dc9 100644 (file)
@@ -31,7 +31,7 @@
             bode(frq, db, phi)
             bode(frq, repf)
             bode(.., Captions)
-            bode(.., Captions, "rad")
+            bode(.., "rad")
         </synopsis>
     </refsynopsisdiv>
     <refsection>
@@ -98,7 +98,8 @@
             <varlistentry>
                 <term>"rad"</term>
                 <listitem>
-                    <para>converts the frequency from Hz into rad/s (multiplies by 2π)
+                    <para>as last optional argument: displays the Bode plot versus Angular frequencies
+                      in rad/s, instead of versus frequencies in Hz.
                     </para>
                 </listitem>
             </varlistentry>
index 74589c3..f099f1f 100644 (file)
@@ -1,6 +1,7 @@
 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 // Copyright (C) 1985 - 2016 - INRIA - Serge Steer
 // Copyright (C) 2012 - 2016 - Scilab Enterprises
+// Copyright (C) 2018 - Samuel GOUGEON
 //
 // This file is hereby licensed under the terms of the GNU GPL v2.0,
 // pursuant to article 5.3.4 of the CeCILL v.2.1.
@@ -103,14 +104,9 @@ function [] = bode(varargin)
     phi = phi';
     [n, mn] = size(d);
 
-    if comments == [] then
-        hx = 0.48;
-    else
-        if size(comments, "*") <> mn then
-            error(mprintf(_("%s: Incompatible input arguments #%d and #%d: Same number of elements expected.\n"), ...
-            fname, refdim, rhs+1))
-        end
-        hx = 0.43;
+    if comments <> [] & size(comments, "*") <> mn then
+        msg = _("%s: Incompatible input arguments #%d and #%d: Same number of elements expected.\n")
+        error(mprintf(msg, fname, refdim, rhs+1))
     end
 
     fig = gcf();
@@ -121,12 +117,14 @@ function [] = bode(varargin)
     axes = sciCurAxes;
     wrect = axes.axes_bounds;
 
-
-    // Magnitude
-    axes.axes_bounds = [wrect(1)+0, wrect(2)+0, wrect(3)*1.0, wrect(4)*hx*0.95];
+    // Magnitude plot
+    // --------------
+    axes.axes_bounds = [wrect(1), wrect(2), wrect(3), wrect(4)*0.5];
     axes.data_bounds = [min(frq), min(d); max(frq), max(d)];
     axes.log_flags = "lnn";
     axes.grid = color("lightgrey")*ones(1, 3);
+    axes.grid_style = [8 8];
+    axes.sub_ticks(1) = 8;
     axes.axes_visible = "on";
     axes.clip_state = "clipgrf";
     if size(d, 2) > 1 & size(frq, 2) == 1 then
@@ -148,12 +146,15 @@ function [] = bode(varargin)
     end
     xtitle("", _("Frequency (Hz)"), _("Magnitude (dB)"));
 
-    // Phase
+    // Phase plot
+    // ----------
     axes = newaxes();
-    axes.axes_bounds = [wrect(1)+0, wrect(2)+wrect(4)*hx, wrect(3)*1.0, wrect(4)*hx*0.95];
+    axes.axes_bounds = [wrect(1), wrect(2)+wrect(4)*0.5, wrect(3), wrect(4)*0.5];
     axes.data_bounds = [min(frq), min(phi); max(frq), max(phi)];
     axes.log_flags = "lnn";
     axes.grid = color("lightgrey")*ones(1, 3);
+    axes.grid_style = [8 8];
+    axes.sub_ticks(1) = 8;
     axes.axes_visible = "on";
     axes.clip_state = "clipgrf";
     if size(phi, 2) > 1 & size(frq, 2) == 1 then
@@ -173,15 +174,34 @@ function [] = bode(varargin)
         e.foreground = 5;
     end
     xtitle("", _("Frequency (Hz)"), _("Phase (degree)"));
+
     // Create legend
+    // -------------
     if comments <> [] then
         c = captions(ephi.children, comments, "lower_caption");
         c.background = get(gcf(), "background");
     end
+
+    // Rendering
     fig.immediate_drawing = immediate_drawing;
-    // Return to the previous scale
+
+    // Post-tuning the vertical distribution of Bode plots
+    // ---------------------------------------------------
+    // (only after rendering, otherwise the legend position is [0 0] (bug))
+    if comments <> [] then
+        LgH = (1-c.position(2))*wrect(4)*0.5; // Legend height
+        // Ah = Magnitude axes height.
+        // Ah + Ah+LgH*Ah/0.5 = wrect(4)  => Ah (1 + 1 + 2*LgH) = wrect(4)
+        Ah = wrect(4)/(2+2*LgH);
+        axes.axes_bounds([2 4]) = [wrect(2)+Ah, wrect(4)-Ah];
+        gcf().children(2).axes_bounds(4) = Ah*1.05;  // Magnitude plot
+    end
+
+    // Returns to the initial axes
     set("current_axes", sciCurAxes);
 
+    // rad/s mode
+    // ----------
     if rad == %t then
         // This function modifies the Bode diagrams for a rad/s display instead of Hz.
         // h is a hanlde of a figure containing Bode diagrams.
index e5bdf2b..3bb4859 100644 (file)
@@ -17,8 +17,9 @@ function str = formatBodeMagTip(datatipHandle)
     unit = gettext("Hz")
     a = datatipHandle.parent.parent;
     while a.type~="Axes", a = a.parent, end
-    if grep(a.x_label.text,"rad/s")~=[] then
-        unit = gettext("rad/s")
+    unit2 = gettext("rad/s")
+    if grep(a.x_label.text, unit2)~=[] then
+        unit = unit2
     end
 
     pt = datatipHandle.data(1:2);
index 928f017..b834bbc 100644 (file)
@@ -17,8 +17,9 @@ function str = formatBodePhaseTip(datatipHandle)
     unit = gettext("Hz")
     a = datatipHandle.parent.parent;
     while a.type~="Axes", a = a.parent, end
-    if grep(a.x_label.text,"rad/s")~=[] then
-        unit = gettext("rad/s")
+    unit2 = gettext("rad/s")
+    if grep(a.x_label.text, unit2)~=[] then
+        unit = unit2
     end
 
     pt = datatipHandle.data(1:2)
index b8dd447..c99469f 100644 (file)
Binary files a/scilab/modules/helptools/images/bode_asymp_en_US_1.png and b/scilab/modules/helptools/images/bode_asymp_en_US_1.png differ
index a5b6050..4dcd4fe 100644 (file)
Binary files a/scilab/modules/helptools/images/bode_asymp_en_US_2.png and b/scilab/modules/helptools/images/bode_asymp_en_US_2.png differ
index fba4652..b6c2232 100644 (file)
Binary files a/scilab/modules/helptools/images/bode_asymp_en_US_3.png and b/scilab/modules/helptools/images/bode_asymp_en_US_3.png differ
index ca046c2..abb61a9 100644 (file)
Binary files a/scilab/modules/helptools/images/bode_asymp_fr_FR_1.png and b/scilab/modules/helptools/images/bode_asymp_fr_FR_1.png differ
index eb658a4..6d2fa26 100644 (file)
Binary files a/scilab/modules/helptools/images/bode_asymp_fr_FR_2.png and b/scilab/modules/helptools/images/bode_asymp_fr_FR_2.png differ
index 12271fd..8c0fea0 100644 (file)
Binary files a/scilab/modules/helptools/images/bode_asymp_fr_FR_3.png and b/scilab/modules/helptools/images/bode_asymp_fr_FR_3.png differ
index 092e0fc..34bc46b 100644 (file)
Binary files a/scilab/modules/helptools/images/bode_asymp_ja_JP_1.png and b/scilab/modules/helptools/images/bode_asymp_ja_JP_1.png differ
index 17b4d8c..e352295 100644 (file)
Binary files a/scilab/modules/helptools/images/bode_asymp_ja_JP_2.png and b/scilab/modules/helptools/images/bode_asymp_ja_JP_2.png differ
index 617495b..b8c8c24 100644 (file)
Binary files a/scilab/modules/helptools/images/bode_asymp_ja_JP_3.png and b/scilab/modules/helptools/images/bode_asymp_ja_JP_3.png differ
index b17978b..d43af1d 100644 (file)
Binary files a/scilab/modules/helptools/images/bode_asymp_pt_BR_1.png and b/scilab/modules/helptools/images/bode_asymp_pt_BR_1.png differ
index 7a4734e..30fcc76 100644 (file)
Binary files a/scilab/modules/helptools/images/bode_asymp_pt_BR_2.png and b/scilab/modules/helptools/images/bode_asymp_pt_BR_2.png differ
index 999c30f..ec94e9f 100644 (file)
Binary files a/scilab/modules/helptools/images/bode_asymp_pt_BR_3.png and b/scilab/modules/helptools/images/bode_asymp_pt_BR_3.png differ
index dadbcb7..3286467 100644 (file)
Binary files a/scilab/modules/helptools/images/bode_asymp_ru_RU_1.png and b/scilab/modules/helptools/images/bode_asymp_ru_RU_1.png differ
index 1277992..0ad9979 100644 (file)
Binary files a/scilab/modules/helptools/images/bode_asymp_ru_RU_2.png and b/scilab/modules/helptools/images/bode_asymp_ru_RU_2.png differ
index 4605271..87bbbb1 100644 (file)
Binary files a/scilab/modules/helptools/images/bode_asymp_ru_RU_3.png and b/scilab/modules/helptools/images/bode_asymp_ru_RU_3.png differ
index 318e092..c6b3d0c 100644 (file)
Binary files a/scilab/modules/helptools/images/bode_en_US_1.png and b/scilab/modules/helptools/images/bode_en_US_1.png differ
index ab3c1fb..ba4cdb5 100644 (file)
Binary files a/scilab/modules/helptools/images/bode_en_US_2.png and b/scilab/modules/helptools/images/bode_en_US_2.png differ
index 19009b1..91bf3b1 100644 (file)
Binary files a/scilab/modules/helptools/images/bode_en_US_3.png and b/scilab/modules/helptools/images/bode_en_US_3.png differ
index b90d0f7..5c9f75b 100644 (file)
Binary files a/scilab/modules/helptools/images/bode_fr_FR_1.png and b/scilab/modules/helptools/images/bode_fr_FR_1.png differ
index 3cf57c1..444bdeb 100644 (file)
Binary files a/scilab/modules/helptools/images/bode_fr_FR_2.png and b/scilab/modules/helptools/images/bode_fr_FR_2.png differ
index d73d408..0e60f4c 100644 (file)
Binary files a/scilab/modules/helptools/images/bode_fr_FR_3.png and b/scilab/modules/helptools/images/bode_fr_FR_3.png differ
index e809cb0..348772f 100644 (file)
Binary files a/scilab/modules/helptools/images/bode_ja_JP_1.png and b/scilab/modules/helptools/images/bode_ja_JP_1.png differ
index 5c1cabc..3faa112 100644 (file)
Binary files a/scilab/modules/helptools/images/bode_ja_JP_2.png and b/scilab/modules/helptools/images/bode_ja_JP_2.png differ
index edd2406..156192e 100644 (file)
Binary files a/scilab/modules/helptools/images/bode_ja_JP_3.png and b/scilab/modules/helptools/images/bode_ja_JP_3.png differ
index 11f00b4..d10c4fb 100644 (file)
Binary files a/scilab/modules/helptools/images/bode_pt_BR_1.png and b/scilab/modules/helptools/images/bode_pt_BR_1.png differ
index e91bdeb..00e3ab2 100644 (file)
Binary files a/scilab/modules/helptools/images/bode_pt_BR_2.png and b/scilab/modules/helptools/images/bode_pt_BR_2.png differ
index 99ca0ce..cd5c749 100644 (file)
Binary files a/scilab/modules/helptools/images/bode_pt_BR_3.png and b/scilab/modules/helptools/images/bode_pt_BR_3.png differ
index 761bbba..eea84df 100644 (file)
Binary files a/scilab/modules/helptools/images/bode_ru_RU_1.png and b/scilab/modules/helptools/images/bode_ru_RU_1.png differ
index 82737e8..25fb45b 100644 (file)
Binary files a/scilab/modules/helptools/images/bode_ru_RU_2.png and b/scilab/modules/helptools/images/bode_ru_RU_2.png differ
index b0cc82b..a5f7673 100644 (file)
Binary files a/scilab/modules/helptools/images/bode_ru_RU_3.png and b/scilab/modules/helptools/images/bode_ru_RU_3.png differ