If required I can specify the colour in a column in the data file but
it would be a lot easier to just specify the threshold to a plot
command.
Try this:
set palette defined (-1 "red", 0 "red", 0 "green", 1 "green")
threshold = 0.2 # put here your threshold
plot 'file.dat' u 1:2:(0.1):($2 > threshold ? 1 : -1) w boxes palette
Another way is to use 'rgbcolor variable':
rgb(r,g,b) = 65536 * int(r) + 256 * int(g) + int(b)
threshold = 0.2
color(th) = th > threshold ? rgb(0, 255, 0) : rgb(255, 0, 0)
plot 'file.dat' u 1:2:(0.1):(color($2)) w boxes lc rgb variable
However, in both cases the fourth column is taken as color argument, the
third specifies the box width. I do not know if its possible to use the
color column and at the same time retain automatic box width adjustment.
In my examples the box width must be set explicitely.
Christoph
This is probably not the most elegant solution, but what the heck, it
works. I guess, by box plot you meant a histogram. If so, do the
following
th=1.0 # This is our threshold
lv=-100.0 # This is just some value, outside the yrange
set yrange [0:*]
f(x)=(x>=th?lv:x)
g(x)=(x<th?lv:x)
p newhistogram, 'something.dat' u (f($1)) lc rgb red, newhistogram at
0, 'something.dat' u (g($1)) lc rgb green
Basically, you plot your data twice, first setting all values that are
above your threshold to 'lv', and then plotting over the same graph
those values that are below your threshold. The only inconvenience is
that you have to set your yrange in advance, but if, for some reason,
you can't do that, you can use the gnuplot variable GPVAL_DATA_Y_MAX
after a dummy plot. You can read on how to make this work here:
http://gnuplot-tricks.blogspot.com/2009/08/plotting-matrix-with-bargraphs.html
Cheers,
Zoltán
The following command is the intended way to do this, but unfortunately
in version 4.2.x it doesn't work for all plot types, and "with boxes"
is one of the plot types it doesn't work for. This oversight is fixed
in current CVS and will be in 4.4
plot "foo" using 1:2:($2 > LIMIT ? ls1 : ls2) with boxes lc variable
(where ls1 and ls2 are linestyle or linetype indices).
As Zoltan points out, version 4.2 does allow a similar command
using 24-bit rgb color info rather than linestyle indices, and with
the restriction that the boxes must be of fixed width
rgb1 = 0x00ff00
rgb2 = 0xff00ff
set boxwidth <width> abs
plot "foo" using 1:2:($2 > LIMIT ? rgb1 : rgb2) with boxes lc rgb variable