Ability to set d3.scale.log base #928

karkumar opened this Issue Nov 28, 2012 · 5 comments


None yet
4 participants


It appears there is no easy way to change the base of d3.scale.log from 10 to something else. Would it be possible to add a d3.scale.log.base() function to do this?


davidjb commented Dec 20, 2012

+1 -- this would definitely be useful.


mbostock commented Jan 23, 2013

The code is mostly setup to support this, although you’d have to change the scale.ticks method to not assume base 10, in addition to exposing a scale.base method to reassign the internal log (and log.pow) function.

chartxyz commented Mar 5, 2013

Hi, Mike,

I have the same issue with the base 2 log. I changed all Math.LN10 to 1 in d3.v3.js. I am not sure if this is the correct way to achieve the base 2 log scale on the axis. Reading the source code is quite difficult for me.

Thank for providing this great tool for the open source community

@mbostock mbostock added a commit that referenced this issue Mar 5, 2013

@mbostock mbostock Add d3.scale.log base. Fixes #928.
Still need to implement sensible behavior for log.ticks without base 10, but I
haven't decided what would be appropriate yet.

mbostock commented Mar 5, 2013

Check out the scale-log-base branch and let me know if that works for you.


mbostock commented Mar 11, 2013

Staged in #1120.

mbostock closed this Mar 11, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment