boxplot / scatter negative y-axis scaling issue - invalid values when ymax = 0

Share RGraph:   Share or Like RGraph on Facebook!

« Back to message list

Enter your email address to get email updates on this topic. You can stop receiving updates by clicking the link in the update email messages.

Posted by RyanG on 27th August 2013
We are evaluating this library for integration into a scientific / engineering data analysis app, and so far find it impressive and easy to working with.

However, we're running into a similar issue as described in other posts, regarding y-axis scaling when the data has negative values, but can provide a more definitive description of this issue.

Here is code for a sample boxplot, with ymin = -36, ymax = 0:

var boxPlot1 = new RGraph.Scatter('bplot1', [[0.5,[-26.97,-19.035,-17.24,-13.745,-5.81,"lightblue","grey",0.2]],[1.5,[-35.2675,-22.24,-15.945,-13.555,-0.5275,"lightblue","grey",0.2]]]);
boxPlot1.Set('chart.labels', ['01','02']);
boxPlot1.Set('chart.xmax', 2);
boxPlot1.Set('chart.ymin', -36);
boxPlot1.Set('chart.ymax', 0);
boxPlot1.Draw();

The resulting y-axis scale displays as -36 to 143, completely out of range & incorrect with the actual data.

Setting ymax to a value on either side of 0 (i.e. -1 or 1) results in correct y-axis scaling / rendering.

Really appreciate any guidance you can provide on this. We're keen to lock it into our app, without needing to do custom workarounds.

Sincerely,
Ryan
Posted by RGraph support on 28th August 2013
Hi there,

You can set the ymax value to 143, but the X axis position is only supported with middle or bottom values:

www.rgraph.net/fiddle/view/an-example-of-a-scatter-chart-with-negative-y-values


Richard, RGraph Support
Posted by RyanG on 28th August 2013
Thanks for responding, however you failed to address the issue I've raised here.

Referencing the sample code I provided earlier, you'll see that I do not set the X axis position, instead accepting whatever the default is.

The issue is with the Y axis, where if ymax is set to 0 the Y values scale irrationally and no longer align with the actual plotted data.

This is clearly a bug, further evidenced by the fact that if I make ymax = -1 or +1, the Y axis values come out correctly, aligning with the data.

Ryan
Posted by RGraph support on 28th August 2013
Hi there,

There's no bug - the Y axes are mirrored when the X axis is in the middle and the ymax refers to the absolute maximum value for both the upper and lower axes.

As I said the Y axis cannot be at the top with the Scatter chart so a ymax value of zero doesn't make sense.

In your case you could set the ymax to 143 and the xaxispos to be in the center:

obj.Set('ymax', 143);
obj.Set('xaxispos', 'center');

The example now has a minimum value to show it.


Richard, RGraph support

Add a reply




« Back to message list