Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re^5: Logarithmic Scale

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

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

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.)

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

    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://11119266]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2022-08-18 02:31 GMT
Find Nodes?
    Voting Booth?

    No recent polls found