0

3 XY datasets to plot:

A) Function plot XY
B) Polynomial, shares X with function, Y is poly_eval(x)
C) Polynomial_error;  X, Y=poly(x) - fct(x)
Range X:  ]0.0 .. 1.0[  (full range 0->1 plus some extra, both sides
Range Y:  ]0.0 .. 1.0[

Wanted: All 3, XY datasets to plot auto-scaled as if it were the ONLY dataset. Expect: "Small", whitespace above/below
Error data spanning entire Y range, not ~0 range near Y=0

Result: Y Range [-10 .. 10]
Error line is flat line in the middle of the graph with ~0 content. In the entire 20 unit Y range, only [0 .. 1] has any data, so 95% is blank space.

IDEAL "Auto" scaling: Support "standard deviation" scaling where a few "outlying" data points will be pushed off the graph to better show the bulk of the data.

Case in point: Error XY data. On the extreme ends, Y error values are gigantic compared to the average, some 14 sigmas out. The auto scaling squashes the 98% of data to within a pixel of zero.

If I calculate the standard deviation and manually set yrange=>[$ylo, $yhi] to something like average +- 1 sigma, it looks informative.

Is there any way to get REASONABLE-SCALE other than max/min or order of magnitude AUTOSCALE?

#!/usr/local/bin/perl -w

use PDL::IO::Misc;
use PDL::Graphics::Gnuplot;
use PDL::Fit::Polynomial;
use PDL::Core;
use List::Util qw(max min);

for($mi=0; $mi < scalar @mxa; $mi++)  {
    @xara = @{$mxa[$mi]};  # @MXA => Array of @xara 
    @yara = @{$mya[$mi]};  # @MYA => Array of @yara 
    $px   = pdl(\@xara);  
    $py   = pdl(\@yara);
    if($mi > 0)  {
        $pw->replot(with=>"lines", linewidth=>5, $px, $py);  # autoscale=>'', 
        next;  
    }
    # Use autoscale=>'' to "set [autoscale] all the axes at once" 
    $pw=gpwin("png", output=>"$imgfn", size=>[$pxres,$pyres,'px'],font=>"=11");
    $pw->plot(title=>"$title", xrange=>[$xlo, $xhi], xlab=>"$xlbl", 
        ylab=>["$ylbl", "offset 1"], autoscale=>'', 
        with=>"lines", linewidth=>5, linetype=>2, linestyle=>1, $px, $py);
}  # End For MI

AutoScale with 5% Data

toolic
  • 57,801
  • 17
  • 75
  • 117

1 Answers1

2

The lack of a complete, minimum working example and a question title that is actually a question or a well-thought-out statement of the problem might be why this question has not been answered yet.

My question for you is, why the use of autoscale=>''?. The documentation for PDL::Graphics::Gnuplot's autoscale plot option states that "By default all axes are autoscaled unless you specify a range on that axis...". So I can produce something like what I think you want by leaving autoscale to its default:

$px=xvals(101)/100;
$py=0.96*sqrt($x)+.02;
$pw->plot(with=>'lines',$px,$py);

That will cause $py to fill almost the entire plot window, with a little bit of buffer on the top and bottom.

As to your second question (the ideal autoscaling that takes into account the variance in your data and doesn't plot extreme outliers), it sounds like you're asking the computer to do what you mean, instead of what you're actually telling it to do. Gnuplot, like most plotting software, will plot all of the data by default. If that's not appropriate, it's up to you to specify appropriate axis ranges. You might also look at Using gnuplot, how to 'cut out' usused y-axis regions of the graph for how to create a broken axis.

Community
  • 1
  • 1
Derek
  • 63
  • 5