private YLabel findYLabel(int yaxis, int desiredMinimumLabelCount) {
        AxisImageParameters aim = im.axisImageParams[yaxis];
        double scaledrange = this.getScaledRange(aim);
        int labelFactor;
        //Check each YLabel definition to see if it's acceptable
        for (int i = 0; ylabels[i].grid > 0; i++) {
            YLabel thisYLabel = ylabels[i];
            //First cut is whether this gridstep would give enough space per gridline
            if (this.getPixelsPerGridline(aim, thisYLabel) > 5 ) {
                //Yep; now we might have to check the number of labels
                if(aim.yminval < 0.0 && aim.ymaxval > 0.0) {
                    //The graph covers positive and negative values, so we need the
                    // desiredMinimumLabelCount number of labels, which is going to
                    // usually be 3, then maybe 2, then only as a last resort, 1. 
                    // So, we need to find out what the label factor would be
                    // if we chose this ylab definition
                    labelFactor = findLabelFactor(aim, thisYLabel);
                    if(labelFactor == -1) {
                        //Default to too many to satisfy the label count test, unless we're looking for just 1	
                        // in which case be sure to satisfy the label count test
                        labelFactor = desiredMinimumLabelCount==1?1:desiredMinimumLabelCount+1; 
                    }
                    //Adding one?  Think fenceposts (need one more than just dividing length by space between)
                    int labelCount = ((int)(scaledrange/thisYLabel.grid)/labelFactor)+1;
                    if(labelCount > desiredMinimumLabelCount) {
                        return thisYLabel; //Enough pixels, *and* enough labels
                    }

                } else {
                    //Only positive or negative on the graph y-axis.  No need to
                    // care about the label count.
                    return thisYLabel;
                }
            }
        }

        double val = 1;
        while(val < scaledrange) {
            val = val * 10;
        }
        return new YLabel(val/10, 1, 2, 5, 10);
    }