[Chart] question about autoScaledLogAxis

Tim Docker tim at dockerz.net
Sun Mar 16 00:45:23 GMT 2014


There’s not currently an easy way to do a log base 2 axis.

The code for the log 10 axis is indeed a bit complex:

https://github.com/timbod7/haskell-chart/blob/master/chart/Graphics/Rendering/Chart/Axis/Floating.hs#L188

this went through several contributed variations to end up in this state. It’s complex due to the fact that it embeds several heuristics to find pleasing looking automatic axis, with the right number of ticks displayed.

If you wanted to have a go at adding log 2 support, I suggest:

   - adding an enum parameter to LogAxisParams with values Base2 and Base10, making Base10 the default.
   - renaming logTicks to log10Ticks
   - writing log2Ticks to generate the appropriate labels, and graduations given an input range
   - Changing autoScaledLogAxis to observe the new enum and call either the existing log10 code or your log2 code.

Cheers,

Tim


On 16 Mar 2014, at 9:42 am, grant weyburne <gbwey9 at gmail.com> wrote:

> Hello,
> 
> Is there an easy way to create an autoScaledLogAxis for log base 2 instead of log base 10. I looked at the code for logTicks in chart\Graphics\Rendering\Chart\Axis\Floating.hs
> but didn't understand what was going on.
> 
> By the way this is an excellent package!
>  
> Thanks for any help.
> Grant
> _______________________________________________
> Chart mailing list
> Chart at projects.haskell.org
> http://projects.haskell.org/cgi-bin/mailman/listinfo/chart




More information about the Chart mailing list