[Scilab-users] 22.5° ray separations in polarplot

Federico Miyara fmiyara at fceia.unr.edu.ar
Thu Mar 28 04:14:08 CET 2019


Heinz,

<disclaimer>
VERY LONG
</disclaimer>

:)

I've found that the gca() (get current axes) handle allows to see and 
control many properties. First run this example:

   x = (0:360)/180*%pi;
   y = 0.5*(1 + cos(x));
   z = 0.5 + 0.5*(1 + cos(x));
   clf
   polarplot([x' x'],[y' z'],[1 2])

Entering

gca()

one of the entities included in the handle are the children. Among much 
other information there is

children: matrix 34x1.

With

gca().children

you get a hint. The answer is:

34 by 1 matrix of handles:
==========================
Text
Segs
Text
Segs

(...)

Text
Arc
Compound

Exactly 34 rows. Yo can see what's inside any one of them by means of, 
for instance,

gca().children(1)

The answer starts

Handle of type "Text" with properties:
======================================
parent: Axes
children: []
visible = "on"
text = "330"
alignment = "left"
data = [1.3825602,-0.7982215,0]

(...)

This says it has a "parent" Axes (it is logical, since this is one of 
the "children" of the current axes), no children (no subordinated 
structure), it is visible, its text is "330", it is lefy aligned, and 
its coordinates are

(x,y,z) = [1.3825602,-0.7982215,0]

They can be retrieved as a variable by means of

gca().children(1).data

It is easy to check that these coordinates represent an angle of 330° 
and a radius slightly larger than the radius of the polar plot border 
circumference (by simple inspection, 1.5). This radius can be calculated as

Rtext = sqrt(sum(gca().children(1).data.^2))

One can change the position and the text to be displayed, for instance, 
to locate the text "NNE" at -22.5°,

theta = -22.5/180*%pi;
gca().children(1).data = Rtext*[cos(theta), sin(theta), 0];
gca().children(1).text = "NNE";

Next is to control the radial lines. These are in children(2). Typing

gca().children(2)

gives the following answer:

Handle of type "Segs" with properties:
======================================
parent: Axes
children: []
visible = "on"
data = [0,0,0;1.3858193,-0.5740251,0]
line_mode = "on"

(...)

The field data represent the coordinates of the extremes of the radial 
lines:

    0.          0.          0.
    1.3858193  -0.5740251   0.

so the radius is the length:

A = gca().children(2).data;
R = sqrt((A(2, :)- A(1, :)).^2);

You can modify the angle this way:

theta = -22.5/180*%pi;
gca().children(2).data(2, :) = R * [cos(theta), R*sin(theta), 0];

This can be repeated with other children, for instance children(3) 
contains the second text and children(4) the second radial line.

Most of this information can be discovered typing

apropos entities

which leads to the graphic entities help. It is very ramified and very 
long, but it is worth it...


There is stil a problem I could not solve, i.e., there are only 24 
children, corresponding 12 to text and 12 to radius, and for a windrose 
you need 16 of each. The other children correspond to the circumference 
arcs of the rho grid of the polar plot.

I don't know how to add or insert more children to the graphic handle...

One possible way (very risky, ensure you make a backup first or work 
with a different function name) is try to find the source for the 
function polarplot and see where is the definition of the number of 
labels and try to customize the function.

Regards,

Federico Miyara






On 27/03/2019 17:37, Heinz Nabielek wrote:
> Friends and colleagues:
>
> Scilab polarplot does a great job displaying my 155,508 measured data pairs wind direction/ wind speed in a split second( while MS Excel is petrified) to make a great wind rose.
>
> One concern: I would like to change the default 30° ray separation into 22.5° separations to indicate N, NNE, NE, ENE, E .... directions.
>
> How can I do that?
>
> Best greetings
> Heinz
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
>
>


---
El software de antivirus Avast ha analizado este correo electrónico en busca de virus.
https://www.avast.com/antivirus




More information about the users mailing list