* Bug 158018 fixed: polarplot() example & demo improved 71/20571/5
Samuel GOUGEON [Sat, 20 Oct 2018 03:27:59 +0000 (05:27 +0200)]
  http://bugzilla.scilab.org/15818

  * polarplot() example could not be subplotted
  * polarplot demo
    - did not show "View code"
    - too often prompted the user

Change-Id: I162b577d53e434e7a52c591091e109deccafe3b0

scilab/CHANGES.md
scilab/modules/graphics/demos/2d_3d_plots/polarplot.dem.sce
scilab/modules/graphics/macros/polarplot.sci

index 3e9b183..2164946 100644 (file)
@@ -589,11 +589,12 @@ Known issues
 * [#15733](http://bugzilla.scilab.org/show_bug.cgi?id=15733): Some fixes after `deg(0*%s)` => `-%inf`.
 * [#15735](http://bugzilla.scilab.org/show_bug.cgi?id=15735): `interp1` yielded some []+n warnings.
 * [#15736](http://bugzilla.scilab.org/show_bug.cgi?id=15736): `unique` failed with complex numbers.
-* [#15747](http://bugzilla.scilab.org/show_bug.cgi?id=15747): no output in overloaded operator crashed Scilab 
+* [#15747](http://bugzilla.scilab.org/show_bug.cgi?id=15747): no output in overloaded operator crashed Scilab
 * [#15753](http://bugzilla.scilab.org/show_bug.cgi?id=15753): `issparse()` returned 0 instead of 1 for sparse booleans.
 * [#15758](http://bugzilla.scilab.org/show_bug.cgi?id=15758): sparse([0 0],1) crashes scilab (regression)
 * [#15762](http://bugzilla.scilab.org/show_bug.cgi?id=15762): `error()` refused multiline error messages.
 * [#15814](http://bugzilla.scilab.org/show_bug.cgi?id=15814): Selecting graphic children with booleans yielded an error.
+* [#15818](http://bugzilla.scilab.org/show_bug.cgi?id=15818): `polarplot()` example could not be subplotted. `polarplot`'s demo did not display 'View code' and too often prompted the user.
 
 
 ### Bugs fixed in 6.0.1:
index 4da3184..1a252b0 100644 (file)
@@ -1,13 +1,11 @@
 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-// Copyright (C) 2010 - Samuel GOUGEON
 // Copyright (C) 2010 - DIGITEO - Sylvestre LEDRU
+// Copyright (C) 2010, 2018 - Samuel GOUGEON
 //
 // This file is released under the 3-clause BSD license. See COPYING-BSD.
 
-
 function demo_polarplot()
     my_handle             = scf(100001);
-    clf(my_handle);
 
     // DEMO START
 
@@ -15,151 +13,79 @@ function demo_polarplot()
     my_handle.figure_name = my_plot_desc;
     tmp = gettext("Please press enter into the Scilab console to see more polarplot examples")
     messagebox(tmp,"modal");
+
     nextMessage = gettext("Press enter to go on...");
     t=linspace(0,1,100)*%pi*2;
+    drawlater
+    clf
+    demo_viewCode("polarplot.dem.sce");
 
     // only 1 quadrant:
-    clf, polarplot(t/4,sin(t/10))
-    title(gettext("polarplot(): Only quadrant(s) reached by data are displayed"))
+    subplot(2,2,1)
+    polarplot(t/4+%pi/2,sin(t/10))
+    subplot(2,2,2)
+    polarplot(t/4,sin(t/10))
+    subplot(2,2,3)
+    polarplot(t/4+%pi,sin(t/10))
+    subplot(2,2,4)
+    polarplot(t/4-%pi/2,sin(t/10))
     show_window(my_handle)
+    drawnow
     input(nextMessage,"s");
 
-    if is_handle_valid(my_handle) == %f then
-        return
-    end
-
-    clf, polarplot(t/4+%pi/2,sin(t/10))
-    title(gettext("Still a single quadrant...")), show_window(my_handle)
-    input(nextMessage,"s");
-
-    if is_handle_valid(my_handle) == %f then
-        return
-    end
-
-    clf, polarplot(t/4+%pi,sin(t/10)), show_window(my_handle)
-    input(nextMessage,"s")
-
-    if is_handle_valid(my_handle) == %f then
-        return
-    end
-
-    clf, polarplot(t/4-%pi/2,sin(t/10)), show_window(my_handle)
-    input(nextMessage,"s");
-
-    if is_handle_valid(my_handle) == %f then
-        return
-    end
-
     // 2 quadrants:
-    clf, polarplot(t/2,sin(t/10)), show_window(my_handle)
-    title(gettext("on 2 quadrants..."))
-    input(nextMessage,"s");
-
-    if is_handle_valid(my_handle) == %f then
-        return
-    end
-
-    clf, polarplot(t/2+%pi/2,sin(t/10)), show_window(my_handle)
-    input(nextMessage,"s");
-
-    if is_handle_valid(my_handle) == %f then
-        return
-    end
-
-    clf, polarplot(t/2+%pi,sin(t/10)), show_window(my_handle)
-    input(nextMessage,"s");
-
-    if is_handle_valid(my_handle) == %f then
-        return
-    end
-
-    clf, polarplot(t/2-%pi/2,sin(t/10)), show_window(my_handle)
+    drawlater
+    clf
+    demo_viewCode("polarplot.dem.sce");
+    xsetech([0 0 0.6 0.5])
+    polarplot(t/2,sin(t/10))
+    xsetech([0 0.5 0.6 0.5])
+    polarplot(t/2+%pi,sin(t/10))
+    subplot(1,3,3)
+    polarplot(t/2-%pi/2,sin(t/10))
+    show_window(my_handle)
+    drawnow
     input(nextMessage,"s");
 
-    if is_handle_valid(my_handle) == %f then
-        return
-    end
-
     // else : full circle:
-    clf, polarplot(t,sin(t/10))
-    title(gettext("Data on the full circle ..."))
-    input(nextMessage,"s");
-
-    if is_handle_valid(my_handle) == %f then
-        return
-    end
-
-    // with rect=
-    clf, polarplot(t/4-1,sin(t/10)-0.3,rect=[-0.18 -0.02 0.27 0.3])
-    title(gettext("A partial viewport may be set with clipping"))
-    input(nextMessage,"s");
-
-    if is_handle_valid(my_handle) == %f then
-        return
-    end
+    drawlater
+    clf
+    demo_viewCode("polarplot.dem.sce");
+    subplot(1,2,1)
+    polarplot(t,sin(t/10))
+    title(gettext("Data on 3 or 4 quadrants"))
 
-    // with negative radii:
-    r = sin(t/10)-0.5;
-    clf, polarplot(t,sin(t/10)-0.5), show_window(my_handle)
-    title(msprintf(gettext("Negative radii are supported:")+" r_min = %.2f",min(r)))
+    subplot(1,2,2)
+    polarplot([sin(2*t') sin(4*t')],[cos(4*t') cos(2*t')],[1,2])
+    title(gettext("Several curves may be plotted at the same time"))
+    show_window(my_handle)
+    drawnow
     input(nextMessage,"s");
 
-    if is_handle_valid(my_handle) == %f then
-        return
-    end
-
+    // Various radii scales:
     t=linspace(0,1,200)*%pi*2;
-    clf, polarplot(t/10-%pi,4600*sin(t/10)), show_window(my_handle)
+    drawlater
+    clf
+    demo_viewCode("polarplot.dem.sce");
+    subplot(2,3,1)
+    polarplot(t/10-%pi,4600*sin(t/10))    // Q3
     title(gettext("Big radii are supported..."))
-    input(nextMessage,"s");
 
-    if is_handle_valid(my_handle) == %f then
-        return
-    end
-
-    clf, polarplot(t/2,4600*sin(t/10)), show_window(my_handle)
-    input(nextMessage,"s");
+    subplot(2,3,4)
+    polarplot(t/4+%pi/2,1.4e-5*sin(t/10))  // Q2
+    title(gettext("... as well as very tiny ones"))
 
-    if is_handle_valid(my_handle) == %f then
-        return
-    end
-
-    clf,   xstring(0,0,"$\magnification{1600}\ $"); // for LaTeXed labels
-    polarplot(t/2,3e5*sin(t/10)), show_window(my_handle)
+    xsetech([0.33 0 0.7 0.5])
+    polarplot(t/2,3e5*sin(t/10))          // Q1+2
     title(gettext("even huge radii, with properly formatted labels..."))
 
-    input(nextMessage,"s");
-
-    if is_handle_valid(my_handle) == %f then
-        return
-    end
-
-    clf, polarplot(t/4,3e5*sin(t/10)), show_window(my_handle)
-    input(nextMessage,"s");
-
-    if is_handle_valid(my_handle) == %f then
-        return
-    end
-
-    clf, polarplot(t/4,1.4e-5*sin(t/10)), show_window(my_handle)
-    title(gettext("... as well as very tiny radii"))
-    input(nextMessage,"s");
-
-    if is_handle_valid(my_handle) == %f then
-        return
-    end
+    // with rect=
+    xsetech([0.33 0.5 0.7 0.48])
+    polarplot(t/4-1,sin(t/10)-0.3, rect=[-0.3 -0.02 0.15 0.3])
+    xlabel(gettext("A partial viewport may be set with clipping"))
 
-    clf, t= 0:.01:2*%pi;
-    polarplot([sin(2*t') sin(4*t')],[cos(4*t') cos(2*t')],[1,2])
-    title(gettext("Several curves may be plotted at the same time"))
     show_window(my_handle)
-
-    if is_handle_valid(my_handle) == %f then
-        return
-    end
-
-    demo_viewCode("polarplot.dem.sce");
-
+    drawnow
 
     // DEMO END
 endfunction
index ac13381..6089102 100644 (file)
@@ -15,7 +15,8 @@ function polarplot(theta,rho,style,strf,leg,rect)
     if rhs<=0 then
         theta=0:.01:2*%pi;
         rho=sin(2*theta).*cos(2*theta)
-        clf();
+        s = gca().axes_bounds;
+        delete(gca()); xsetech(s) // clears & keeps the current axes area
         polarplot(theta,rho)
         return
     end