Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

consider 'log' progression for scale-y #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

splendido
Copy link

When computing linear regressions on logarithmic scales, log function should be applied to y values and the resulting range compensated accordingly.

The scatter example shown at http://www.zingchart.com/blog/2016/01/06/scatter-plot-examples/ is clearly not well represented by the trend line.

The proposed changes were tested with this fiddle: http://jsfiddle.net/yuu9hsyn/2/ (see lines 1459-1543)
and the result shows the computed trend line is now correct:

logaritmictrendline

As a side note, it seems progression: "log" is mapped to the Math.log function hence computing the natural logarithm of y values: in my humble opinion, Math.log10 would be a more appropriate choice since scientific plots usually make use of the base 10 logarithm in place of the natural one.
In case you'll ever decide to switch to Math.log10 make sure to modify the proposed changes to use Math.pow(10, x) in place of Math.exp to compensate the computed range result.

When computing linear regressions on logarithmic scales, log function should be applied to y values and the resulting range compensated accordingly.
@splendido
Copy link
Author

just for completeness: this is the result obtained with the current code:

logarithmictrendline_old

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant