|
From: Ethan A M. <me...@uw...> - 2020-09-10 20:20:26
|
I am confused as to what exactly you are trying to plot.
The intent of the "bins" option is similar to the "smooth frequency" option.
It derives an approximation to the distribution of values read from
a single column of data.
If there is a second column of data this is interpreted as a weight.
To show the distribution of values for f(x) over a given range of x,
the plotting command could be
plot sample [xmin:xmax:increment] '+' using (f(x)) bins {binwidth=foo}
If I rewrite your test case in this form, shown as a histogram, it becomes
plot sample [0:100:1] '+' using (sin(x)) bins binwidth=0.1 with boxes
The autoscaling works correctly on both x and y, and remains correct if
I plot instead "with lines". Note that this is a single column of data, so
the samples have uniform weights.
Your test case creates this same set of samples but stores it in a
data block with two columns x and f(x). To reproduce the plot from
the stored samples the command would be
plot $data using 2 bins binwidth=0.1
Your test script provides no "using" specifier, however, so the plot
command draws values from column 1 (essentially the numbers 0 to 100)
and weights each one by the value in the second column (sin(x)).
The presence of negative weights in particular confuses the program.
I don't rule out the possibility that there is a legitimate use for such
but the code assumes positive weights, typically either 1 or a set of
fractional values summing to 1 so that the distribution is normalized.
Also since the range of values is [0:100], using a bin width of 0.1 means
that the vast majority of bins are empty.
This produces the strange-looking plot you saw.
If your test case is intended as a simple stand-in for some real world
data that does in fact use negative weights, please clarify the
expected properties of the resulting distribution and I will try to
modify the program's expectations to allow it. As it stands, the
programs expectations about y values lead it to totally mis-assign
all the points as "inrange" and therefore not clipped.
Ethan
|