Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>An algorithm (example values <code>$min=-186</code> and <code>$max=+153</code> as limits):</p> <ol> <li><p>Take these two limits <code>$min</code>, <code>$max</code> and mark them if you wish</p></li> <li><p>Calculate the difference between <code>$max</code> and <code>$min</code>: <code>$diff = $max - $min</code><br> <code>153 - (-186) = 339</code></p></li> <li><p>Calculate 10th logarithm of the difference <code>$base10 = log($diff,10)</code> = 2,5302</p></li> <li><p>Round down: <code>$power = round($base10)</code> = 2.<br> This is your tenth power as base unit</p></li> <li><p>To calculate <code>$step</code> calculate this:<br> <code>$base_unit = 10^$power</code> = 100;<br> <code>$step = $base_unit / 2</code>; (if you want 2 ticks per one <code>$base_unit</code>).</p></li> <li><p>Calculate if <code>$min</code> is divisible by <code>$step</code>, if not take the nearest (round up) one<br> (in the case of <code>$step = 50</code> it is <code>$loop_start = -150</code>)</p></li> <li><p><code>for ($i=$loop_start; $i&lt;=$max; $i++=$step){ // $i's are your ticks</code></p></li> <li><p>end</p></li> </ol> <p>I tested it in Excel and it gives quite nice results, you may want to increase its functionality, </p> <p>for example (in point 5) by calculating <code>$step</code> first from <code>$diff</code>,<br> say <code>$step = $diff / 4</code> and round <code>$step</code> in such way that <code>$base_unit</code> is divisible by <code>$step</code>; </p> <p>this will avoid such situations that you have between (101;201) four ticks with <code>$step=25</code> and you have 39 steps <code>$step=25</code> between 0 and 999.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload