예제 #1
0
 def choose_diverging_palette(h_neg=IntSliderWidget(min=0,
                                                    max=359,
                                                    value=220),
                              h_pos=IntSliderWidget(min=0,
                                                    max=359,
                                                    value=10),
                              s=IntSliderWidget(min=0, max=99, value=74),
                              l=IntSliderWidget(min=0, max=99, value=50),
                              sep=IntSliderWidget(min=1, max=50, value=10),
                              n=(2, 16),
                              center=["light", "dark"]):
     pal[:] = diverging_palette(h_neg, h_pos, s, l, sep, n, center)
     palplot(pal)
     if as_cmap:
         colors = diverging_palette(h_neg, h_pos, s, l, sep, 256, center)
         _update_lut(cmap, colors)
예제 #2
0
 def choose_cubehelix(n_colors=IntSliderWidget(min=1, max=15, value=6),
                      start=FloatSliderWidget(min=0, max=3, value=0),
                      rot=FloatSliderWidget(min=-1, max=1, value=.4),
                      gamma=FloatSliderWidget(min=0, max=5, value=1),
                      hue=FloatSliderWidget(min=0, max=1, value=.8),
                      dark=FloatSliderWidget(min=0, max=1, value=.15),
                      light=FloatSliderWidget(min=0, max=1, value=.85),
                      reverse=False):
     palplot(
         cubehelix_palette(n_colors, start, rot, gamma, hue, dark, light,
                           reverse))
예제 #3
0
 def choose_cubehelix(n_colors=IntSliderWidget(min=2, max=16, value=9),
                      start=FloatSliderWidget(min=0, max=3, value=0),
                      rot=FloatSliderWidget(min=-1, max=1, value=.4),
                      gamma=FloatSliderWidget(min=0, max=5, value=1),
                      hue=FloatSliderWidget(min=0, max=1, value=.8),
                      light=FloatSliderWidget(min=0, max=1, value=.85),
                      dark=FloatSliderWidget(min=0, max=1, value=.15),
                      reverse=False):
     pal[:] = cubehelix_palette(n_colors, start, rot, gamma, hue, light,
                                dark, reverse)
     palplot(pal)
     if as_cmap:
         colors = cubehelix_palette(256, start, rot, gamma, hue, light,
                                    dark, reverse)
         _update_lut(cmap, np.c_[colors, np.ones(256)])
예제 #4
0
def _widget_abbrev_single_value(o):
    """Make widgets from single values, which can be used as parameter defaults."""
    if isinstance(o, string_types):
        return TextWidget(value=unicode_type(o))
    elif isinstance(o, dict):
        return DropdownWidget(values=o)
    elif isinstance(o, bool):
        return CheckboxWidget(value=o)
    elif isinstance(o, float):
        min, max, value = _get_min_max_value(None, None, o)
        return FloatSliderWidget(value=o, min=min, max=max)
    elif isinstance(o, int):
        min, max, value = _get_min_max_value(None, None, o)
        return IntSliderWidget(value=o, min=min, max=max)
    else:
        return None
예제 #5
0
X = np.arange(minimo, maximo, prec)
puntos = np.array(soluciones)


def p(t):
    plt.plot(
        X,
        func(X),
        maximo_x,
        func(maximo_x),
        'or',  # Punto rojo: Máximo de la función
        inicial,
        func(inicial),
        'oy',  # Punto amarillo: Solución inicial
        puntos[t],
        func(puntos[t]),
        'og',  # Punto verde: Solución intermedia
        mejor,
        func(mejor),
        'ob')  # Punto azul: Mejor solución hallada
    plt.show()


i = interact(p,
             t=IntSliderWidget(min=0, max=len(soluciones) - 1, step=1,
                               value=0))

print("Cantidad de soluciones evaluadas:", evaluaciones)

# In[ ]:
def plot_tree_interactive():
    from IPython.html.widgets import interactive, IntSliderWidget
    slider = IntSliderWidget(min=0, max=8, step=1, value=0)
    return interactive(plot_tree, max_depth=slider)