Algorithm for “nice” grid line intervals on a graph

前端 未结 14 1236
长发绾君心
长发绾君心 2020-11-28 01:45

I need a reasonably smart algorithm to come up with \"nice\" grid lines for a graph (chart).

For example, assume a bar chart with values of 10, 30, 72 and 60. You k

相关标签:
14条回答
  • 2020-11-28 02:27

    If you are trying to get the scales looking right on VB.NET charts, then I've used the example from Adam Liss, but make sure when you set the min and max scale values that you pass them in from a variable of type decimal (not of type single or double) otherwise the tick mark values end up being set to like 8 decimal places. So as an example, I had 1 chart where I set the min Y Axis value to 0.0001 and the max Y Axis value to 0.002. If I pass these values to the chart object as singles I get tick mark values of 0.00048000001697801, 0.000860000036482233 .... Whereas if I pass these values to the chart object as decimals I get nice tick mark values of 0.00048, 0.00086 ......

    0 讨论(0)
  • 2020-11-28 02:27

    In python:

    steps = [numpy.round(x) for x in np.linspace(min, max, num=num_of_steps)]
    
    0 讨论(0)
提交回复
热议问题