Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re^3: Logarithmic Scale

by kikuchiyo (Friar)
on Jul 13, 2020 at 15:35 UTC ( #11119261=note: print w/replies, xml ) Need Help??

in reply to Re^2: Logarithmic Scale
in thread Logarithmic Scale

Thanks, that makes the layout of the data clear.

Now that I've thought about it, I've never seen a polar plot distorted in a way you describe. The polar axis is in decibels, so it already uses logarithmic scale - by "making the outer donuts larger", as you say, you actually want to undo the logarithmic scaling, at least partially. In any case, I see this as a cosmetic alteration that may be harmful, because it changes the shape of the curve you want to show, without good reason.

With that in mind, here is a gnuplot script that produces a graph close to what you want:

set polar set rr [-40:10] set rtics 10 unset border unset xtics unset ytics set grid lt 1 lc rgb "blue" f(x) = (x+50)**2 g(x) = sqrt(x)-50 set nonlinear r via f(r) inverse g(r) plot '/tmp/foo.n2p' u ($0>0&&$0<=361 ? $0*pi/180. : 1/0):1 w l lw 2 n +otit

The scaling function (that determines the spacing of the grid circles) is a square function (f(x) in the script) as opposed to exponential. You could use this function in your script if you prefer to stay with your pure perl solution.

Replies are listed 'Best First'.
Re^4: Logarithmic Scale
by aplonis (Pilgrim) on Jul 13, 2020 at 17:37 UTC

    Thank you! Very helpful. Since you mentioned, I did an image search in Bing for "antenna polar plot" and find a mix of grid circles, some evenly spaced to maintain the dBi scaling, others undoing it to reveal the real-world lobe profile.

    And in the case of the Nec2Go program's default, it was showing real-world which I was trying to emulate.

    So now I'm thinking I should make it an option to scale the grid either way. Which means I'm half done, versus wrong. I still want the other, as it is more intuitive to look at when wanting to overlay the outline onto a great circle map for positioning. Being able to clearly read the values below -20 dBi is of very small interest, yes?

    Gan, KY8D

      Ahh, now I understand the purpose of the distorted graph. Still, I think it's a distortion, because the real difference between 10 dB and -40 dB is five orders of magnitude - if you plot that on a polar chart with linear (undone logarithmic) scaling, you get a spike, not a slightly altered, "real-world" shape (and you can forget about everything under 0 dB, not -20).

      But I realize that for your application it is the kind of graph you and your users expect and understand. In that case it might be a good thing to provide an option to display either mode. To produce graphs that look like your PNG example (and like the examples I've found on the internet) you could use an exponential unscaling function with a very small exponent (something between 1.05 and 1.1 seemed to work for me).

      (By the way, one advantage of gnuplot is that it has an interactive mode, which helps to rapidly prototype the kind of chart you want, and find the right parameters, and then you can go and reuse the commands in a script that produces a publication-ready graph from the same data.)

        Just as you say. Employing a square function, per your example, seems to work out more like the ones I was thinking about. A distortion from decibels, and also not really undoing logarithmic, as you observed. But perhaps with the advantage of putting the ring for 0 dBi very nearly at the exact center, allowing more space for the primary data-of-interest. In the sample PNG graphic (a screenshot from Nec2Go) it is clear that they've done similar. The values for -20, -30, -40 are scrunched down in the very center. And it is -10 dBi which is at about the middle rung, while +8.9 dBi is the outermost rung (that being max output).

        At least my puzzle is solved! It must wait until after work before I can try putting it into an SVG and deciding whether to keep it. Chances are, maybe you've persuaded me in that direction. In which case, I'll leave it as was. Alternately, I might keep both and make the choice selectable. I thank you for your kind assistance.

        #!C:\Users\gstarl\Strawberry\perl\bin\perl # my $scale_min = 0; # Center point of radius in pixels. my $scale_max = 100; # Outer circumference in pixels. my $scale_span = $scale_max - $scale_min; # Example fake data # Also, positions of rings in azimuthal plot. my @data = (-50, -40, -30, -20, -10, 0, 10, 20); # Extract limits and span from data array. sub get_min_max_span { my @data = @_; my $min; my $max; for my $i (0 .. $#data) { if ($i == 0) { $min = $max = $data[0] } else { $min = $data[$i] if $min > $data[$i]; $max = $data[$i] if $max < $data[$i]; } } return $min, $max, $max-$min; } # Collect from data. my ($data_min, $data_max, $data_span) = get_min_max_span(@data); # Scale values in dBi for plot as pixels. # Also to place the dBi rings on plot. sub scale_value_for_graph { my ($value, $data_min, $data_max, $data_span, $scale_max) = @_; return ($value - $data_min)**2 * $scale_max / $data_span**2; } # Try it out. Goodie! The zero dBi position is about in the middle. for (@data) { print "\n$_ -> " . scale_value_for_graph($_, $data_min, $data_max, + $data_span, $scale_max); }

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11119261]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2022-08-10 18:00 GMT
Find Nodes?
    Voting Booth?

    No recent polls found