I am working on a plotting function and need to define where to place axis labels. In calculating the increments between each label I want to avoid labels at 142, 284, etc and would rather want them at 150, 300, etc.
However, the numbers are not always in the same range. Here is how I plan to round them using a function:
- between 0 and 1: round up to first decimal
- between 1 and 10: round up to full integer or .5
- between 11 and 20: round up to full integer
- between 21 and 100: round up to multiple of 5
- between 101 and 200: round up to multiple of 10
- between 201 and 1000: round up to multiple of 50
- between 1001 and 2000: round up to multiple of 100
- between 2001 and 10000: round up to multiple of 500
My problem lies in number 2. How do round to multiples of .5? Also, is there an alternative standard function that can be used for these kinds of labeling problems?