Maths equation question

I have a graph run from xml that could have anywhere from 1 to 31 points on the x axis. The problem relates to the labels on the graph, the dimensions are small so when theres only say 4 or 5 points it looks fine but when it gets past 20 it starts to look rubbish and the labels overlap. I want to work out an equation to only show 4 of the labels at any one time, but the maths is causing me headaches - my maths side of programming has always let me down so any advice/help would be fantastic.
anyone any pointers?
thanks
:ducky: