[rrd-users] Re: plot positive and negative in different colours

Alex van den Bogaerdt alex at ergens.op.het.net
Tue Oct 31 11:21:06 MET 2006


On Tue, Oct 31, 2006 at 09:39:03AM +0000, Dave Holland wrote:


> I have a data value which can be positive or negative. I'm trying to
> figure out how to make rrd plot graphs with the line one colour for
> positive data, and a different colour for negative data.

As you have figured out already, you have to draw two lines.

> So far I have this:
[edited]
> 
>   rrdtool graph out.png \
>      DEF:x=foo.rrd:data:LAST
>      CDEF:n=x,DUP,0,LT,* \
>      CDEF:p=x,DUP,0,GT,* \
>      AREA:n#ff0000 \
>      AREA:p#0000ff
> 
> which gets me a filled graph; positive in blue, negative in red. OK so
> far: http://eyas.biff.org.uk/~dave/test3.png

This creates two lines, { 0 or positive, 0 or negative }

> But I'd like a line graph. If I change AREA to be LINE2 then I get a
> weird discontinuity when the data changes sign. See for example
> http://eyas.biff.org.uk/~dave/test4.png just before the end of week 41.
> There's also the issue of the horizontal line at zero; I can disguise
> that with a HRULE but it's a bit ugly.

You probably want to use { Unknown or positive, Unknown or negative }
which can be achieved with IF and UNKN; something like n=x,0,LT,x,UNKN,IF

> How can I get a single line plotted which changes colour appropriately?

Try plotting 'x' in one color, and overlapping part of it with the
other color (e.g. plot LINE1:x#0000ff LINE2:n#ff0000)

-- 
Alex van den Bogaerdt
http://www.vandenbogaerdt.nl/rrdtool/

--
Unsubscribe mailto:rrd-users-request at list.ee.ethz.ch?subject=unsubscribe
Help        mailto:rrd-users-request at list.ee.ethz.ch?subject=help
Archive     http://lists.ee.ethz.ch/rrd-users
WebAdmin    http://lists.ee.ethz.ch/lsg2.cgi



More information about the rrd-users mailing list