Código:
from __future__ import unicode_literals import numpy as np from numpy import ma from matplotlib import scale as mscale from matplotlib import transforms as mtransforms from matplotlib.ticker import Formatter, FixedLocator class EscalaAcumuladaGumbel(mscale.ScaleBase): name = 'gumbel' def __init__(self, axis, **kwargs): mscale.ScaleBase.__init__(self) umbral = kwargs.pop("umbral", 0.9999) if umbral >= 1.0: raise ValueError("umbral debe ser mayor que 0.0 o menor que 1.0") self.umbral = umbral def get_transform(self): return self.TransformacionAcumuladaGumbel(self.umbral) def set_default_locators_and_formatters(self, axis): class TresDecimales(Formatter): def __call__(self, x, pos=None): return '%.3f' % x axis.set_major_locator(FixedLocator(np.arange(0.0, 1.0, 0.05))) axis.set_major_formatter(TresDecimales()) axis.set_minor_formatter(TresDecimales()) def limit_range_for_scale(self, vmin, vmax, minpos): return max(vmin, -self.umbral), min(vmax, self.umbral) class TransformacionAcumuladaGumbel(mtransforms.Transform): input_dims = 1 output_dims = 1 is_separable = True def __init__(self, umbral): mtransforms.Transform.__init__(self) self.umbral = umbral def transform(self, a): masked = ma.masked_where((a < -self.umbral) | (a > self.umbral), a) if masked.mask.any(): return 0.156516164484 + (0.0915834783405*(-ma.log(-ma.log(a)))) else: return 0.156516164484 + (0.0915834783405*(-np.log(-np.log(a)))) def inverted(self): return EscalaAcumuladaGumbel.TransformacionInversaAcumuladaGumbel(self.umbral) class TransformacionInversaAcumuladaGumbel(mtransforms.Transform): input_dims = 1 output_dims = 1 is_separable = True def __init__(self, umbral): mtransforms.Transform.__init__(self) self.umbral = umbral def transform(self, a): return np.exp(-np.exp(-a)) def inverted(self): return EscalaAcumuladaGumbel.TransformacionAcumuladaGumbel(self.umbral) mscale.register_scale(EscalaAcumuladaGumbel) if __name__ == '__main__': import matplotlib.pyplot as plt Datos = np.array([ 2690.0, 2700.0, 2700.667, 2701.333, 2702.0, 3196.0, 2372.0, 2395.0, 2128.0, 2727.0, 2431.0, 2850.0, 2216.0, 2057.0, 2269.0, 2208.0, 2628.0, 2729.0, 2588.0, 3448.0, 2508.0, 3081.0, 2417.0, 2770.0, 2283.0, 2455.0, 1963.0, 2786.0, 2885.0, 2357.0, 3422.0, 2423.0, 2148.0, 1305.0, 2472.0, 2186.0, 2720.0, 2430.0, 2304.0, 2556.0, 2625.0, 2164.0, 2585.0, ]) DatosOrdenados = np.sort(Datos) mu = 2353.157 sigma = 297.961 y1 = ( DatosOrdenados - mu) / sigma x1 = np.exp(-np.exp(-y1)) plt.plot(x1, y1, 'ro', lw=2) plt.gca().set_xscale('gumbel') plt.xlabel('F(z)') plt.ylabel('z') plt.title('Papel de probabilidad de Gumbel') plt.xticks(rotation='vertical', fontsize=7) plt.grid(True) plt.show()