def scale(x, range, drange):
    """
    From real coordinates get rendered coordinates.

    :param x: source value
    :param range: (min,max) of x
    :param drange: (min,max) of sx
    :return: scaled x (sx)
    """
    (rx1, rx2) = float(range[0]), float(range[1])
    (sx1, sx2) = float(drange[0]), float(drange[1])
    return (sx2 - sx1) * (x - rx1) / (rx2 - rx1) + sx1