I want to display three labels on the y-axis: min, middle and max. max - min = 9572.
The easiest way to find middle is 9572 / 2 = 4786. These values are not nice so Excel would probably increase the interval to 1000 and set middle to 500.
How do I compute nice values for my y-axis when min and max are given? min and/or max might be negative.
Good question! Recently I had solved similar problem recently and what I have done:
Choose good looking starting point for min label. Take your actual minimum, divide by chosen step (5000). Round the result (you can use floor for minimum and ceil for maximum) and multiply it by chosen step. For example, if min = -3400 and max = 2700:
scaleMin = floor(-3400 / 5000) * 5000 = -5000
scaleMax = ceil(2700 / 5000) * 5000 = 5000
This will give three labels: -5000, 0 and 5000. If you can tolerate last mark on y-axis below graph maximum, don't just use ceil (or floor). Compute how much percents graph maximum is off the mark, and add one step if it's too much.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With