<kevintheobald <at> frontier.com> writes:
>
> Given the following data (simplified example):
>
> 3 2
> 2 3
> 3 2
> 3 2
>
> I can plot a vertical-bar histogram with 1-unit buckets with the data in
column 2 as follows:
>
> hist(x,width)=width*floor(x/width)+width/2.0
> set boxwidth 1
> plot 'gp' u (hist($2,1)):(1.0) sm f w boxes
>
> producing the expected result, with one bar of height 3 from 2-3 and one bar
of height 1 from 3-4.
>
> Now I want to show data only from rows with 3 in column 1. Most info I've
seen on this recommends using ?: to turn
> unwanted rows into garbage, e.g., 1/0:
>
> plot 'gp' u (hist((($1==3)?$2:(1/0)),1)):(1.0) sm f w boxes
>
> Unfortunately, I don't get what I expect (a single bar of height 3 from 2-3).
Instead, I get a bar of height 2
> with a horizontal line in the middle at y=1. I think it's actually
superimposing two bars, one of height 1
> and one of height 2, because if I add another row '3 2' at the end, the height
goes up to 3 (instead of 4) and the
> line is still at y=1. It's as if the "bad" data in row 2 "breaks up" the data
and plot doesn't realize row 1 and
> rows 3-4 really belong to the same bucket, and it draws two bars, one in front
of the other.
>
> Is there another way to do this? (Would prefer within gnuplot, rather than
"filter the data before going
> into gnuplot.) Or is this a known problem recently fixed? (I'm using 4.6.0.)
>
using the 'smooth frequency' option of the 'plot' command
you could set the y-value to 0.0 for unwanted data instead
of making data points undefined:
plot 'gp' u (hist($2,1)):(($1==3)?1.0:0.0) sm f w boxes
|