def __call__(self, x, pos=None): # The location will come in psu. Need to convert to EC. # We have already done the work in ConversionLocator to make sure # that these will turn out attractive xnew = psu_ec_25c(x) if x >= 0.0 else -psu_ec_25c(abs(x)) n_digits = int(np.log10(xnew)) + 1 if n_digits == 1: xnew = 0. elif n_digits == 2: xnew = np.around(xnew, -1) elif n_digits > 2: xnew = np.around(xnew, np.max((-n_digits + 2, -2))) else: raise Exception() t = "%5.0f" % xnew return t
def tick_values(self, vmin, vmax): ''' The idea of this function is to determine tick locations in psu that will be neat numbers once converted and labeled as EC. The way we do this is to convert the bounds vmin and vmax to ec and using AutoLocator to come up with neat EC values. Then we back convert these values to psu. ''' # vmin and vmax are in psu # Determine "neat values of EC for tick locations vmin_ec = psu_ec_25c(vmin) if vmin >= 0. else -psu_ec_25c(abs(vmin)) vmax_ec = psu_ec_25c(vmax) if vmax >= 0. else -psu_ec_25c(abs(vmax)) # Determine "neat" values of EC for tick locations auto_ticks = AutoLocator.tick_values(self, vmin_ec, vmax_ec) # Now determine the locations in psu, since the axis is psu for # locations and EC for labeling. convert_ticks = [ x for x in ec_psu_25c(auto_ticks) if x >= 0. and x <= 35. ] return convert_ticks