Reputation: 10697
I'm drawing a chart with logarithmic scale that I can zoom and pan. In the process of zooming and panning I need to be prepared for drawing nice tick labels. My general problem is: given two points, x0
and x1
, create a subdivision of n
elements in log scale that 'looks nice'. I have gone through the math gems algorithms about nice grid line but it doesn't work that well for logarithmic scale. Any pointers?
Upvotes: 3
Views: 1132
Reputation: 373082
One option would be to use the standard algorithms for nicely subdividing up tick marks for a normal range of values by simply computing the logarithm of the range you want ti divide and applying the linear algorithm directly. That is, if you already have an algorithm that solves this problem in the case where you want linearly-distributed values, transforming your data by applying the logarithm to each value will then let you compute the logarithm if the tick marks you want. You can then raise these tick marks to the appropriate power to invert the transformation, ending up with the tick marks for the log plot.
Upvotes: 1