[Scilab-users] Polarplot help

classic Classic list List threaded Threaded
10 messages Options
Claus Futtrup Claus Futtrup
Reply | Threaded
Open this post in threaded view
|

[Scilab-users] Polarplot help

Dear Scilabers

This weekend I'm trying to do some polar plots and experiment with GUI.

What I'm trying to do is quite similar to Example 3 in the help:

I work with  loudspeakers and in our industry it's standard to have the zero degree angle up the y-axis (as in above Example 3).

How can I rotate the labels of the polarplot so that zero is up the y-axis instead of out the x-axis? Alternatively, how can I disable the labels?

Best regards,
Claus

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Philippe Roux Philippe Roux
Reply | Threaded
Open this post in threaded view
|

Re: Polarplot help

Hi,

Le 20/01/2018 à 11:08, Claus Futtrup a écrit :
>
>
> How can I rotate the labels of the polarplot so that zero is up the
> y-axis instead of out the x-axis? Alternatively, how can I disable the
> labels?

look at the Axis handle, the labels of a polar plot are additional
children  of "Text" . Try this example :


clf
t = 0:0.01:2*%pi;
polarplot(t, -1 + sin(t));
A=gca()  // get the axis handle
A.children//  look at all its children
//The labels are those of "Text" type
id=find(A.children.type="Text" )// get their id
//then modify the properties of the handles
A.children(id).visible="off" // no labels
A.children(id).visible="on" // all labels
A.children(id).text="mylabel" // change labels
for k=id
    A.children(k).text=string(k);
end


Philippe

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Claus Futtrup Claus Futtrup
Reply | Threaded
Open this post in threaded view
|

Re: Polarplot help

Hi Philippe

Thank you for the pointer. It works. To everybodys amusement, here comes a script (with data reduced from more than 13000 to 21, so it can be posted here). The reason is I have a new problem. Plotting in this case 3 set of data, polarplot seems to auto_scale and turning it off doesn't work (??). Please see this one:

// Test data
frequencies = [200 2000 20000]; // Hz
angles = [0 30 60 90 120 150 180]; // degrees - convert to radians!
mag00 = [69.253448 92.163385 87.414209]; // on-axis freq-response
mag30 = [68.461357 90.569082 76.073549];
mag60 = [65.842262 90.745621 74.152067];
mag90 = [59.420658 80.893365 55.975304];
mag120 = [52.505173 80.795915 44.363582];
mag150 = [53.829987 59.793715 42.443964];
mag180 = [55.650341 73.457973 55.608187];
magnitudes = [mag00' mag30' mag60' mag90' mag120' mag150' mag180']; 
// 3 freq x 7 angles = 21 data points, put into a matrix.
// In the complete dataset there's 183 frequencies and 72 angles.

negative_angles = -angles(2:7);
neg_angle_magnitudes = magnitudes(:,2:7);

angles = [angles negative_angles];
magnitudes = [magnitudes neg_angle_magnitudes];

[angles idx] = gsort(angles,'g','i');
magnitudes = magnitudes(:,idx);

// Polar plot example:
    polplt = scf();
    p = gca(); // p = "polarplot" ... how ingenious :-/
    polarplot(%pi*angles/180,magnitudes(1,:));
    p.auto_scale = "off";
    polarplot(%pi*angles/180,magnitudes(2,:)); // index 2 = 2 kHz
    polarplot(%pi*angles/180,magnitudes(3,:));
    legend("200 Hz","2 kHz","20 kHz");
    p = gca(); // p = "polarplot" ... how ingenious :-/
    idx=find(p.children.type=="Text");
    p.children(idx).visible="off";

My "problem" is I cannot just specify polarplot to plot all three curves in one go. So I execute one at the time, but now see the axis changes for each of them (in the same figure)...

I hope it makes sense what I'm trying to do and my problem is understandable.

Best regards,
Claus

On Sat, Jan 20, 2018 at 4:21 PM, philippe <[hidden email]> wrote:
Hi,

Le 20/01/2018 à 11:08, Claus Futtrup a écrit :
>
>
> How can I rotate the labels of the polarplot so that zero is up the
> y-axis instead of out the x-axis? Alternatively, how can I disable the
> labels?

look at the Axis handle, the labels of a polar plot are additional
children  of "Text" . Try this example :


clf
t = 0:0.01:2*%pi;
polarplot(t, -1 + sin(t));
A=gca()  // get the axis handle
A.children//  look at all its children
//The labels are those of "Text" type
id=find(A.children.type="Text" )// get their id
//then modify the properties of the handles
A.children(id).visible="off" // no labels
A.children(id).visible="on" // all labels
A.children(id).text="mylabel" // change labels
for k=id
    A.children(k).text=string(k);
end


Philippe

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Rafael Guerra Rafael Guerra
Reply | Threaded
Open this post in threaded view
|

Re: Polarplot help

In reply to this post by Claus Futtrup

Hi Claus,

 

For the angles orientation problem in polar plot and correct labelling, here below a simple solution:

 

// START OF CODE
clf
t = 0:0.01:2*%pi;
t90 = %pi/2 - t;  //redefine angle-convention consistent with loudspeaker plots
theta = t;   // keep Scilab angles for theta
rho = -1 + sin(t90);  // use new angle mapping for rho
polarplot(theta, rho);
a=gca();
set(a,'rotation_angles',[180,0]);  // rotate plot axes
// END OF CODE

 

Regards,

Rafael


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Rafael Guerra Rafael Guerra
Reply | Threaded
Open this post in threaded view
|

Re: Polarplot help

In reply to this post by Claus Futtrup

Hi Claus,

 

Regarding your problem of not being able to plot all curves in one go preserving the scales, if I am not mistaken this can be solved by invoking polarplot with a single call using array notation.

See example here below with 2 curves for simplicity:

 

// START OF CODE

clf

t = 0:0.01:2*%pi;

t90 = %pi/2 - t;  //redefine angle-convention consistent with loudspeaker plots

theta = t;   // keep Scilab angles for theta

rho1 = 1 + sin(t90).^2;  // use new angle mapping for rho1

rho2 = 1 + 2*cos(t90).^2;  // use new angle mapping for rho2

polarplot([theta,theta], [rho1,rho2]);

a=gca();

set(a,'rotation_angles',[180,0]);  // rotate plot axes

// END OF CODE

 

Regards,

Rafael


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Claus Futtrup Claus Futtrup
Reply | Threaded
Open this post in threaded view
|

Re: Polarplot help

In reply to this post by Rafael Guerra
Hi Rafael

Thank you. It works. Interesting how the 'set' command alone can do the trick:

set(a,'rotation_angles',[180,0]);

Excellent. :-)

Best regards,
Claus

On Sun, Jan 21, 2018 at 12:55 PM, Rafael Guerra <[hidden email]> wrote:

Hi Claus,

 

For the angles orientation problem in polar plot and correct labelling, here below a simple solution:

 

// START OF CODE
clf
t = 0:0.01:2*%pi;
t90 = %pi/2 - t;  //redefine angle-convention consistent with loudspeaker plots
theta = t;   // keep Scilab angles for theta
rho = -1 + sin(t90);  // use new angle mapping for rho
polarplot(theta, rho);
a=gca();
set(a,'rotation_angles',[180,0]);  // rotate plot axes
// END OF CODE

 

Regards,

Rafael


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users



_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Claus Futtrup Claus Futtrup
Reply | Threaded
Open this post in threaded view
|

Re: Polarplot help

In reply to this post by Rafael Guerra
Hi Rafael

Array notation. After Reading your suggestion I looked at the documentation of polarplot and this is not explicitly treated, so I missed that one. Thank you.

Best regards,
Claus

On Sun, Jan 21, 2018 at 1:08 PM, Rafael Guerra <[hidden email]> wrote:

Hi Claus,

 

Regarding your problem of not being able to plot all curves in one go preserving the scales, if I am not mistaken this can be solved by invoking polarplot with a single call using array notation.

See example here below with 2 curves for simplicity:

 

// START OF CODE

clf

t = 0:0.01:2*%pi;

t90 = %pi/2 - t;  //redefine angle-convention consistent with loudspeaker plots

theta = t;   // keep Scilab angles for theta

rho1 = 1 + sin(t90).^2;  // use new angle mapping for rho1

rho2 = 1 + 2*cos(t90).^2;  // use new angle mapping for rho2

polarplot([theta,theta], [rho1,rho2]);

a=gca();

set(a,'rotation_angles',[180,0]);  // rotate plot axes

// END OF CODE

 

Regards,

Rafael


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users



_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Claus Futtrup Claus Futtrup
Reply | Threaded
Open this post in threaded view
|

Re: Polarplot help

Hi Rafael, et al.

I now see that - actually - example 2 of the documentation indeed does plot two graphs. There's no explanation to the example ... sometimes the documentation for Scilab functions is incredibly hard to read for someone who doesn't already know in advance.

/Claus

On Sun, Jan 21, 2018 at 1:41 PM, Claus Futtrup <[hidden email]> wrote:
Hi Rafael

Array notation. After Reading your suggestion I looked at the documentation of polarplot and this is not explicitly treated, so I missed that one. Thank you.

Best regards,
Claus

On Sun, Jan 21, 2018 at 1:08 PM, Rafael Guerra <[hidden email]> wrote:

Hi Claus,

 

Regarding your problem of not being able to plot all curves in one go preserving the scales, if I am not mistaken this can be solved by invoking polarplot with a single call using array notation.

See example here below with 2 curves for simplicity:

 

// START OF CODE

clf

t = 0:0.01:2*%pi;

t90 = %pi/2 - t;  //redefine angle-convention consistent with loudspeaker plots

theta = t;   // keep Scilab angles for theta

rho1 = 1 + sin(t90).^2;  // use new angle mapping for rho1

rho2 = 1 + 2*cos(t90).^2;  // use new angle mapping for rho2

polarplot([theta,theta], [rho1,rho2]);

a=gca();

set(a,'rotation_angles',[180,0]);  // rotate plot axes

// END OF CODE

 

Regards,

Rafael


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users




_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Samuel GOUGEON Samuel GOUGEON
Reply | Threaded
Open this post in threaded view
|

[Scilab-users] polarplot improvements (pre-SEP) <= Re: Polarplot help

In reply to this post by Claus Futtrup
Hello Clauss,

After a first polarplot upgrade in 2010, i started writting some other improvements in 2016, first about still improving angular and radial labels positionning. Yesterday, i took the opportunity of your message to post on the CodeReview the polarplot.sci in progress, and to go on a bit, mainly about proper labels for polar datatips.
You can already use the scripts as is: https://codereview.scilab.org/#/c/19684/
Just click on the polarplot.sci link, and then you may download it, or copy/past the content.

The trick with gca().rotation_angles reminded y Rafael is well known, but due to labels uncentered on their anchor, using it currently shifts labels (see the screenshot below). This is fixed in the CodeReview version.

If you want to be fully back-compatible with this new polarplot.sci, you should simply comment lines
performing some glue(). This won't prevent other improvements working.

Other improvements can be proposed, as listed in the review header:
  • DONE:
    • centering of angular labels: Already allows shifting the 0° position and the angular direction (clockwise/trigo), using gca().rotation_angles
    • Optimized positionning of radial labels
    • Glue into 4 compounds lines of the radial frame lines of the circular frame angular labels radial labels (not backcompatible => To be discussed carefully).
    • polarplot() canceled external drawlater(): FIXED
    • Datatips: implement a convenient default display function
  • WIP:
  • TO BE ANALYZED
    • Angular labels with a rect box disappear or are unclipped over neighbouting axes.
    • Enable specifying major values for the radial and angular frame (to be analyzed)
    • Enable radial logarithmic scale
    • Extend replot() to polar plots

This may be seen as a "pre-SEP" :). A proper SEP will be required. To come.

In my opinion, the trick with gca().rotation_angles is not fully convenient because

  • it may switch xlabel() and ylabel() positions, what could be disturbing
  • radial labels can be turned displayed along a row, what must be avoided to avoid overlays when labels are quite long.

So, the final implementation won't use this trick.

Later, with a priority clearly lower, the same job shall be done for graypolarplot().

Cheers
Samuel


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Claus Futtrup Claus Futtrup
Reply | Threaded
Open this post in threaded view
|

Re: polarplot improvements (pre-SEP) <= Re: Polarplot help

Hi Samuel

It looks like excellent work. I checked my polar plot and the labels are indeed a little bit off (mostly visible with 3-digit numbers, i.e. 120, 150, 180 and so on degrees). It works OK for now. I think your upgraded polarplot should go into the main tree - the plots as seen on the picture you included looks excellent.

If overplotting could be fixed, that would also be very nice.

P.S. it reminds me that Scilab 6 was released about a year ago. Normally such a first release with such big changes will require some bug fixing, but surprisingly this seems not to be the case. Impressive how well 6.0.0 was executed (and it also took a couple of years ...). I could not execute my latest script (with the polar and contour plots) in Scilab 5 -- it ran out of memory.

I wonder if anyone can say what's up in regard to Scilab releases?

Best regards,
Claus


On Sun, Jan 21, 2018 at 9:41 PM, Samuel Gougeon <[hidden email]> wrote:
Hello Clauss,

After a first polarplot upgrade in 2010, i started writting some other improvements in 2016, first about still improving angular and radial labels positionning. Yesterday, i took the opportunity of your message to post on the CodeReview the polarplot.sci in progress, and to go on a bit, mainly about proper labels for polar datatips.
You can already use the scripts as is: https://codereview.scilab.org/#/c/19684/
Just click on the polarplot.sci link, and then you may download it, or copy/past the content.

The trick with gca().rotation_angles reminded y Rafael is well known, but due to labels uncentered on their anchor, using it currently shifts labels (see the screenshot below). This is fixed in the CodeReview version.

If you want to be fully back-compatible with this new polarplot.sci, you should simply comment lines
performing some glue(). This won't prevent other improvements working.

Other improvements can be proposed, as listed in the review header:
  • DONE:
    • centering of angular labels: Already allows shifting the 0° position and the angular direction (clockwise/trigo), using gca().rotation_angles
    • Optimized positionning of radial labels
    • Glue into 4 compounds lines of the radial frame lines of the circular frame angular labels radial labels (not backcompatible => To be discussed carefully).
    • polarplot() canceled external drawlater(): FIXED
    • Datatips: implement a convenient default display function
  • WIP:
  • TO BE ANALYZED
    • Angular labels with a rect box disappear or are unclipped over neighbouting axes.
    • Enable specifying major values for the radial and angular frame (to be analyzed)
    • Enable radial logarithmic scale
    • Extend replot() to polar plots

This may be seen as a "pre-SEP" :). A proper SEP will be required. To come.

In my opinion, the trick with gca().rotation_angles is not fully convenient because

  • it may switch xlabel() and ylabel() positions, what could be disturbing
  • radial labels can be turned displayed along a row, what must be avoided to avoid overlays when labels are quite long.

So, the final implementation won't use this trick.

Later, with a priority clearly lower, the same job shall be done for graypolarplot().

Cheers
Samuel


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users



_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users