Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Algorithm for nice log labels

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?

like image 767
Ricardo Marimon Avatar asked Feb 15 '26 17:02

Ricardo Marimon


1 Answers

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.

like image 72
templatetypedef Avatar answered Feb 19 '26 07:02

templatetypedef



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!