def get_label_coords(self, distances, XX, YY, ysize, lw):
hysize = int(ysize/<NUM_LIT:2>)<EOL>adist = np.argsort(distances)<EOL>for ind in adist:<EOL><INDENT>x, y = XX[ind][hysize], YY[ind][hysize]<EOL>if self.too_close(x,y, lw):<EOL><INDENT>continue<EOL><DEDENT>else:<EOL><INDENT>return x,y, ind<EOL><DEDENT><DEDENT>ind = adist[<NUM_LIT:0>]<EOL>x, y = XX[ind][hysize], YY[ind][hysize]<EOL>return x,y, ind<EOL>
labels are ploted at a location with the smallest
        dispersion of the contour from a straight line
        unless there's another label nearby, in which case
        the second best place on the contour is picked up
        if there's no good place a label isplotted at the
        beginning of the contour