Round a positive axis maximum up to a human-friendly tick boundary.
(value)
| 23 | |
| 24 | |
| 25 | def nice_ceil(value): |
| 26 | """Round a positive axis maximum up to a human-friendly tick boundary.""" |
| 27 | if value <= 0: |
| 28 | return 1.0 |
| 29 | |
| 30 | magnitude = 10 ** math.floor(math.log10(value)) |
| 31 | normalized = value / magnitude |
| 32 | for step in (1, 2, 2.5, 3, 4, 5, 10): |
| 33 | if normalized <= step: |
| 34 | return step * magnitude |
| 35 | return 10 * magnitude |
| 36 | |
| 37 | |
| 38 | def nice_step(span, target_ticks): |