0
$\begingroup$

Hard to come up with a good title. I'm looking for an algorithm to adjust a range. Say I have 5.34 as min and 23.96 as max value. This gives it a range/difference of 18.62. I now want to divide this number by n (in my case always 5.5) and result of that division should be a "nice" or meaningful number to make a series from.

In this case we could enlarge the difference to 22 and get a series of 4,8,12,16,20,24 and set the limits to 4 and 26. The first problem obviously is the definition of a "nice number". A whole number fits that but also 0.25 or 0.5 would be good.

Having trouble coming up with an algorithm. Of course mod is involved but i above case 5-25 would be better fit as humans will look at this. How would I encode this "order of importance"? Scale can be arbitrary so maybe 100 is good or 100000. So a fixed list won't work either?

$\endgroup$
1
$\begingroup$

Take a look how plotting programs do this -- for example gnuplot. They also get odd values and need to find ways to display that with a meaningful scale.

| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ I'm sure you are right and the reason for this question as you have guessed correctly is about plotting. The limitation here being that one axis needs to be adjust depending on the other axis. $\endgroup$ – beginner_ Nov 8 '17 at 5:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.