rrdgraph: Negative values with --logarithmic

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

rrdgraph: Negative values with --logarithmic

Christian Garbs
Hi there,

looking through the mailing list archive, I found several requests
like mine over the last years:

"Why won't negative values show up in my graph when I use --lograrithmic?"

The answer was mostly that a logarithm is not defined for negative
numbers.

What I want to achieve (and what I think those other proponents also
had in mind) is that I essentially have some of my data mirrored at
the x-axis for better readability (don't draw two values on top of
each other).

For example I plot outgoing packets on my network as a positive values
while I plot the incoming packets via CDEF:output=0,outputx,- as
negative values.  So the outgoing rate is shown above the x-axis and
the incoming rate below the x-axis.

To tame network spikes somewhat I want to change the graph mode to
logarithmic.  This works for the positive values, but the negative
values simply vanish.  I just want the same transormation that happens
to the positive values applied 'mirrored' the the negative values.

Think of something like a "display-logarithm" function defined like
this:


double disp_log(double y)
{
        if (y == 0) {
                return 0;
        } else if (y > 0) {
                return log(y);
        } else {
                return -log(-y);
        }
}


While "-log(-y)" might look weird in a mathematical context I think that
it makes sense in describing "do the same as for positive values, only
in the other direction".


I have had a look at rrdgraph.c and think that I found the calculation
of the final y value for a given data point in the ytr() method.  But
I did not yet fully figure out how im->minval is computed (im->minval
seems to be the reason for negative values to be cut off).

(And if this makes sense at all, it should be probably be controlled
 by a commandline parametera and I have not yet started to look what
 else needs to be changed then: commandline parsing, internal
 configuration state, manpages, documentation...)


What do you think of this?
Would the be a useful feature?
Could this somehow be implemented?


Regards
Christian
--
....Christian.Garbs....................................https://www.cgarbs.de

  _../|_
='__   _~-.
     \'  ~-`\._
            |/~`

_______________________________________________
rrd-users mailing list
[hidden email]
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users
Reply | Threaded
Open this post in threaded view
|

Re: rrdgraph: Negative values with --logarithmic

Alex van den Bogaerdt-5
> What I want to achieve (and what I think those other proponents also
> had in mind) is that I essentially have some of my data mirrored at
> the x-axis for better readability (don't draw two values on top of
> each other).
>
> For example I plot outgoing packets on my network as a positive values
> while I plot the incoming packets via CDEF:output=0,outputx,- as
> negative values.  So the outgoing rate is shown above the x-axis and
> the incoming rate below the x-axis.

So, what you want to show is the outcome of a normal logaritmic function,
but mirrored. Instead of a new function...

> To tame network spikes somewhat I want to change the graph mode to
> logarithmic.  This works for the positive values, but the negative
> values simply vanish.  I just want the same transormation that happens
> to the positive values applied 'mirrored' the the negative values.
>
> Think of something like a "display-logarithm" function defined like
> this:
>
>
> double disp_log(double y)
> {
> if (y == 0) {
> return 0;
> } else if (y > 0) {
> return log(y);
> } else {
> return -log(-y);
> }
> }
>
>
> While "-log(-y)" might look weird in a mathematical context I think that
> it makes sense in describing "do the same as for positive values, only
> in the other direction".

... can't you just use CDEF:mirrored=logresult,-1,* ?
Or am I missing something ?

_______________________________________________
rrd-users mailing list
[hidden email]
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users
Reply | Threaded
Open this post in threaded view
|

Re: rrdgraph: Negative values with --logarithmic

Christian Garbs
On Mon, Oct 17, 2016 at 03:01:11AM +0200, Alex van den Bogaerdt wrote:

> > What I want to achieve (and what I think those other proponents also
> > had in mind) is that I essentially have some of my data mirrored at
> > the x-axis for better readability (don't draw two values on top of
> > each other).
> >
> > For example I plot outgoing packets on my network as a positive values
> > while I plot the incoming packets via CDEF:output=0,outputx,- as
> > negative values.  So the outgoing rate is shown above the x-axis and
> > the incoming rate below the x-axis.
>
> So, what you want to show is the outcome of a normal logaritmic function,
> but mirrored. Instead of a new function...

Basically, yes, but because of the y axis I think I need some special
logic in rrdgraph (see below).

> > To tame network spikes somewhat I want to change the graph mode to
> > logarithmic.  This works for the positive values, but the negative
> > values simply vanish.  I just want the same transormation that happens
> > to the positive values applied 'mirrored' the the negative values.
> >
> > Think of something like a "display-logarithm" function defined like
> > this:
> >
> >
> > double disp_log(double y)
> > {
> > if (y == 0) {
> > return 0;
> > } else if (y > 0) {
> > return log(y);
> > } else {
> > return -log(-y);
> > }
> > }
> >
> >
> > While "-log(-y)" might look weird in a mathematical context I think that
> > it makes sense in describing "do the same as for positive values, only
> > in the other direction".
>
> ... can't you just use CDEF:mirrored=logresult,-1,* ?
> Or am I missing something ?

This would indeed give me the correct results and would draw a correct
graph, but the y axis grid would not be logarithmic:

If I put the values "1000" and "-1000" into a CDEF using normal and
'mirrored' LOG, I'll graph the values "3" and "-3".  The y grid will
propably autoscale to "-10 … 10" and show my values as "3" and "-3"
instead of "1000" and "-1000".

When I use --logarithmic, the positive values are also LOGed, but the y
axis will be scaled logarithmic as well, so the y axis will show
"1000" (or "10e3" or "1k") next to the graph value.

If I could get a logarithmic y axis without using --logarithmic (for
both positive and negative values), using LOG in a CDEF would indeed
be a solution.

Regards
Christian
--
....Christian.Garbs....................................https://www.cgarbs.de

"Die Berühmtheit mancher Zeitgenossen hängt mit der Blödheit
 der Bewunderer zusammen."                -- Heiner Geissler

_______________________________________________
rrd-users mailing list
[hidden email]
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users
Reply | Threaded
Open this post in threaded view
|

Re: rrdgraph: Negative values with --logarithmic

Christian Garbs
In reply to this post by Christian Garbs
On Sun, Oct 16, 2016 at 09:31:18PM +0200, Christian Garbs wrote:

> What I want to achieve (and what I think those other proponents also
> had in mind) is that I essentially have some of my data mirrored at
> the x-axis for better readability (don't draw two values on top of
> each other).
>
> For example I plot outgoing packets on my network as a positive values
> while I plot the incoming packets via CDEF:output=0,outputx,- as
> negative values.  So the outgoing rate is shown above the x-axis and
> the incoming rate below the x-axis.
>
> To tame network spikes somewhat I want to change the graph mode to
> logarithmic.  This works for the positive values, but the negative
> values simply vanish.  I just want the same transormation that happens
> to the positive values applied 'mirrored' the the negative values.

I now have a first working prototype, see
https://github.com/oetiker/rrdtool-1.x/pull/757

I can plot a "negative logarithm" just like I described.

There are still two problems:

 - Y axis legend is not drawn
 - Y axis autoscale does not work, you have to explicitely set --lower-limit

Would anybody with more knowledge about rrdgraph.c like to have a look
at these problems?

Thanks!
Christian
--
....Christian.Garbs....................................https://www.cgarbs.de
"I can't believe you don't believe me."
(Note: this tactic is successful in focusing the other person's
 attention away from the subject)

_______________________________________________
rrd-users mailing list
[hidden email]
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users