Exemple #1
0
def plot_circle_density(nodes, degrees, plot_width=800, plot_height=800):
    print("Plotting circle density graph")
    TOOLS="hover,pan,wheel_zoom,box_zoom,reset,click,previewsave"    
    plt.figure(plot_width=plot_width, plot_height=plot_height, tools=TOOLS)
    theta = np.random.uniform(0, 2*np.pi, size=len(nodes))
    max_d, min_d = np.max(degrees), np.min(degrees)
    scale = 1.0/np.log(degrees) - 1.0/np.log(max_d)
    xs = np.cos(theta)*scale
    ys = np.sin(theta)*scale
    source_dict = dict(
        xs = xs,
        ys = ys,
        degrees = degrees,
        nodes = nodes,
        alphas = np.log(degrees)/np.log(max(degrees)),
    )
    source = ColumnDataSource(source_dict)
    plt.hold(True)
    plt.circle('xs', 'ys', source=source,
               radius=0.0025,
               fill_alpha='alphas',
               x_axis_type=None, y_axis_type=None, 
               title="Density Distribution of Degrees")
    plt.text([max(xs), max(xs)], 
             [.95*max(ys), .85*max(ys)], 
             ["distance from center = 1 / log(deg)",
              "angle = random"], 
             angle=0,
             text_baseline="bottom", text_align="right")
    hover = [t for t in plt.curplot().tools if isinstance(t, HoverTool)][0]
    hover.tooltips = OrderedDict([
        ('node', '@nodes'), ('degree', '@degrees')
    ])
    plt.hold(False)
    return plt.curplot()
Exemple #2
0
def plot_3(data, ss):
    """t-SNE embedding of the parameters, colored by score
    """
    scores = np.array([d['mean_test_score'] for d in data])
    # maps each parameters to a vector of floats
    warped = np.array([ss.point_to_moe(d['parameters']) for d in data])

    # Embed into 2 dimensions with t-SNE
    X = TSNE(n_components=2).fit_transform(warped)

    e_scores = np.exp(scores)
    mine, maxe = np.min(e_scores), np.max(e_scores)
    color = (e_scores - mine) / (maxe - mine)
    mapped_colors = map(rgb2hex, cm.get_cmap('RdBu_r')(color))

    bk.figure(title='t-SNE (unsupervised)')
    bk.hold()
    df_params = nonconstant_parameters(data)
    df_params['score'] = scores
    bk.circle(
        X[:, 0], X[:, 1], color=mapped_colors, radius=1,
        source=ColumnDataSource(df_params), fill_alpha=0.6,
        line_color=None, tools=TOOLS)
    cp = bk.curplot()
    hover = cp.select(dict(type=HoverTool))
    format_tt = [(s, '@%s' % s) for s in df_params.columns]
    hover.tooltips = OrderedDict([("index", "$index")] + format_tt)

    xax, yax = bk.axis()
    xax.axis_label = 't-SNE coord 1'
    yax.axis_label = 't-SNE coord 2'
Exemple #3
0
def perf_std_discrete(ticks,
                      avgs,
                      stds,
                      legend=None,
                      std_width=0.3,
                      plot_width=1000,
                      plot_height=300,
                      color=BLUE,
                      alpha=1.0,
                      **kwargs):
    plotting.rect(ticks,
                  avgs, [std_width for _ in stds],
                  2 * np.array(stds),
                  line_color=None,
                  fill_color=color,
                  fill_alpha=alpha * 0.5,
                  plot_width=plot_width,
                  plot_height=plot_height,
                  **kwargs)
    plotting.hold(True)
    plotting.line(ticks,
                  avgs,
                  line_color=color,
                  line_alpha=alpha,
                  legend=legend)
    plotting.circle(ticks,
                    avgs,
                    line_color=None,
                    fill_color=color,
                    fill_alpha=alpha)
    plotting.grid().grid_line_color = 'white'
    plotting_axis()

    plotting.hold(False)
Exemple #4
0
def get_plottag(script_path):
    """ Saves js in script_path and returns tag for embedding in html
    """
    import numpy as np
    import pandas as pd
    import os

    y_data = np.random.randn(100)
    x_data = pd.date_range('31-Aug-2014', periods=len(y_data))

    figure(x_axis_type='datetime', 
           tools='pan,wheel_zoom,box_zoom,reset,previewsave,crosshair', 
           name='test plot')
    hold()
    line(x_data, y_data,
         line_color="#D95B43", line_width=4, alpha=0.7, 
         legend='random', 
         background_fill= '#cccccc')
    circle(x_data, y_data, 
           color='red', fill_color=None, size=6, 
           legend='random')
    curplot().title = 'Test Plot'
    xaxis().axis_label='date'
    yaxis().axis_label='some random numbers'
    grid().grid_line_color='white'
    grid().grid_line_alpha = 0.5

    plotid = curplot()._id
    script_path = os.path.join(script_path, plotid+'.js')
    js, tag = autoload_static(curplot(), CDN, script_path=script_path)
    with open(script_path, 'w') as f:
        f.write(js)
        
    return tag
Exemple #5
0
def radialchart(nodes, edgelist):
    ids, times, relevances = nodes.T
    times *= 2
    node_x, node_y = _radial_layout(nodes)
    nodepos = np.asarray((node_x, node_y)).T
    hold()
    circle(node_x, node_y, color="red", size=relevances * 4, alpha=relevances)
    coords = nodepos[edgelist].reshape((len(edgelist), 4)).T
    segment(coords[0], coords[1], coords[2], coords[3], line_alpha=0.35)
Exemple #6
0
def radialchart(nodes, edgelist):
    ids, times, relevances = nodes.T
    times *= 2
    node_x, node_y = _radial_layout(nodes)
    nodepos = np.asarray((node_x, node_y)).T
    hold()
    circle(node_x, node_y, color="red", size=relevances*4, alpha=relevances)
    coords = nodepos[edgelist].reshape((len(edgelist), 4)).T
    segment(coords[0], coords[1], coords[2], coords[3],
            line_alpha=0.35)
def build_punchcard(datamap_list, concept_list,
                    radii_list, fields_in_concept_list,
                    datamaps, concepts,
                    plot_width=1200, plot_height=800):

    source = ColumnDataSource(
        data=dict(
            datamap=datamap_list,  # x
            concept=concept_list,  # y
            radii=radii_list,
            fields_in_concept=fields_in_concept_list,
        )
    )
    output_file('')
    hold()
    figure()
    plot_properties = {
        'title': None,
        'tools': "hover,resize,previewsave",
        'y_range': [get_datamap_label(datamap) for datamap in datamaps],
        'x_range': concepts,
        'plot_width': plot_width,
        'plot_height': plot_height,
    }

    rect('concept', 'datamap',  # x, y
         1, 1,  # height, width
         source=source,
         color='white',  # put in background
         **plot_properties)

    circle('concept', 'datamap',  # x, y
           size='radii',
           source=source,
           color='black',
           **plot_properties)

    grid().grid_line_color = None
    x = xaxis()
    x.major_label_orientation = pi / 4
    hover = [t for t in curplot().tools if isinstance(t, HoverTool)][0]

    hover.tooltips = OrderedDict([
        ("Datamap", "@datamap"),
        ("Concept", "@concept"),
        ("Fields", "@fields_in_concept"),
    ])

    return curplot().create_html_snippet(
        static_path=settings.STATIC_URL,
        embed_save_loc=settings.BOKEH_EMBED_JS_DIR,
        embed_base_url=reverse('bokeh'),
    )
Exemple #8
0
def coverage(
    s_channels,
    threshold,
    s_vectors=(),
    title="no title",
    swap_xy=True,
    x_range=None,
    y_range=None,
    color=C_COLOR,
    c_alpha=1.0,
    alpha=0.5,
    **kwargs
):

    x_range, y_range = ranges(s_channels, x_range=x_range, y_range=y_range)
    try:
        xv, yv = zip(*(s[:2] for s in s_vectors))
    except ValueError:
        xv, yv = [], []
    if swap_xy:
        x_range, y_range = y_range, x_range
        xv, yv = yv, xv

    plotting.circle(
        xv,
        yv,
        radius=threshold,
        x_range=x_range,
        y_range=y_range,
        fill_color=hexa(color, 0.35),
        fill_alpha=c_alpha,
        line_color=None,
        title=title,
        **kwargs
    )
    plotting.hold(True)

    union = shapely.ops.unary_union([shapely.geometry.Point(*sv_i).buffer(threshold) for sv_i in s_vectors])
    boundary = union.boundary
    if isinstance(boundary, shapely.geometry.LineString):
        boundary = [boundary]

    for b in boundary:
        x, y = b.xy
        x, y = list(x), list(y)
        if swap_xy:
            x, y = y, x
        plotting.patch(x, y, fill_color=None, line_color=hexa(color, 0.75))
        plotting.hold(True)

    plotting_axis()
    plotting.hold(False)
Exemple #9
0
def perf_std_discrete(ticks, avgs, stds, legend=None,
                      std_width=0.3, plot_width=1000, plot_height=300,
                      color=BLUE, alpha=1.0, **kwargs):
    plotting.rect(ticks, avgs, [std_width for _ in stds], 2*np.array(stds),
                  line_color=None, fill_color=color, fill_alpha=alpha*0.5,
                  plot_width=plot_width, plot_height=plot_height, **kwargs)
    plotting.hold(True)
    plotting.line(ticks, avgs, line_color=color, line_alpha=alpha, legend=legend)
    plotting.circle(ticks, avgs, line_color=None, fill_color=color, fill_alpha=alpha)
    plotting.grid().grid_line_color = 'white'
    plotting_axis()

    plotting.hold(False)
Exemple #10
0
 def test_figure(self):
     p = plt.figure()
     self.assertEqual(plt.curplot(), p)
     q = plt.circle([1,2,3], [1,2,3])
     self.assertEqual(plt.curplot(), q)
     self.assertNotEqual(p, q)
     r = plt.figure()
     self.assertEqual(plt.curplot(), r)
     self.assertNotEqual(p, r)
     self.assertNotEqual(q, r)
     plt.hold()
     s = plt.circle([1,2,3], [1,2,3])
     self.assertEqual(plt.curplot(), s)
     self.assertEqual(r, s)
Exemple #11
0
 def test_figure(self):
     p = plt.figure()
     self.assertEqual(plt.curplot(), p)
     q = plt.circle([1,2,3], [1,2,3])
     self.assertEqual(plt.curplot(), q)
     self.assertNotEqual(p, q)
     r = plt.figure()
     self.assertEqual(plt.curplot(), r)
     self.assertNotEqual(p, r)
     self.assertNotEqual(q, r)
     plt.hold()
     s = plt.circle([1,2,3], [1,2,3])
     self.assertEqual(plt.curplot(), s)
     self.assertEqual(r, s)
Exemple #12
0
def coverage(s_channels,
             threshold,
             s_vectors=(),
             title='no title',
             swap_xy=True,
             x_range=None,
             y_range=None,
             color=C_COLOR,
             c_alpha=1.0,
             alpha=0.5,
             **kwargs):

    x_range, y_range = ranges(s_channels, x_range=x_range, y_range=y_range)
    try:
        xv, yv = zip(*(s[:2] for s in s_vectors))
    except ValueError:
        xv, yv = [], []
    if swap_xy:
        x_range, y_range = y_range, x_range
        xv, yv = yv, xv

    plotting.circle(xv,
                    yv,
                    radius=threshold,
                    x_range=x_range,
                    y_range=y_range,
                    fill_color=hexa(color, 0.35),
                    fill_alpha=c_alpha,
                    line_color=None,
                    title=title,
                    **kwargs)
    plotting.hold(True)

    union = shapely.ops.unary_union([
        shapely.geometry.Point(*sv_i).buffer(threshold) for sv_i in s_vectors
    ])
    boundary = union.boundary
    if isinstance(boundary, shapely.geometry.LineString):
        boundary = [boundary]

    for b in boundary:
        x, y = b.xy
        x, y = list(x), list(y)
        if swap_xy:
            x, y = y, x
        plotting.patch(x, y, fill_color=None, line_color=hexa(color, 0.75))
        plotting.hold(True)

    plotting_axis()
    plotting.hold(False)
Exemple #13
0
def crawlchart(nodes, edgelist):
    """ edges is an Nx2 array of node ids 
    """
    ids, times, relevances = nodes.T
    times *= 2
    node_y = _rectilinear_layout(nodes)
    hold()
    #circle(times, node_y, color="gray", size=1)

    # Draw the relevant points in a different color
    circle(times, node_y, color="red", size=relevances * 6, alpha=relevances)

    nodepos = np.asarray((times, node_y)).T
    coords = nodepos[edgelist].reshape((len(edgelist), 4)).T
    segment(coords[0], coords[1], coords[2], coords[3], line_alpha=0.35)
Exemple #14
0
def bokeh_highlights(s_vectors, n=1, color="#DF4949", swap_xy=True, radius=2.5, alpha=0.5):
    """n is the number of effect per cell to pick"""
    xv, yv = zip(*s_vectors)
    if swap_xy:
        xv, yv = yv, xv
    plotting.circle(
        xv,
        yv,
        fill_color=None,
        line_color=color,
        line_alpha=alpha,
        line_width=0.5,
        radius=radius,
        radius_units="screen",
    )
Exemple #15
0
 def test_merge(self):
     d1 = document.Document()
     d2 = document.Document()
     p1 = circle([1], [2])
     p2 = circle([1], [2])
     d1.add(p1)
     d2.add(p2)
     json_objs = d1.dump()
     json_objs = protocol.deserialize_json(protocol.serialize_json(json_objs))
     d2.merge(json_objs)
     assert d2.context._id == d1.context._id
     assert len(d2.context.children) == 2
     assert d2.context is d2._models[d2.context._id]
     pcs = [x for x in d2._models.values() if x.__view_model__ == "PlotContext"]
     assert len(pcs) == 1
Exemple #16
0
 def test_figure(self):
     plt.figure()
     self.assertEqual(plt.curplot(), None)
     p = plt.circle([1,2,3], [1,2,3])
     self.assertEqual(plt.curplot(), p)
     plt.figure()
     self.assertEqual(plt.curplot(), None)
Exemple #17
0
def crawlchart(nodes, edgelist):
    """ edges is an Nx2 array of node ids 
    """
    ids, times, relevances = nodes.T
    times *= 2
    node_y = _rectilinear_layout(nodes)
    hold()
    #circle(times, node_y, color="gray", size=1)

    # Draw the relevant points in a different color
    circle(times, node_y, color="red", size=relevances*6, alpha=relevances)

    nodepos = np.asarray((times,node_y)).T
    coords = nodepos[edgelist].reshape((len(edgelist), 4)).T
    segment(coords[0], coords[1], coords[2], coords[3],
            line_alpha=0.35)
Exemple #18
0
    def test_axis(self):
        plt.figure()
        p = plt.circle([1,2,3], [1,2,3])
        self.assertEqual(len(plt.axis()), 2)

        expected = set(plt.axis())

        ax = LinearAxis()
        expected.add(ax)
        p.above.append(ax)
        self.assertEqual(set(plt.axis()), expected)

        ax2 = LinearAxis()
        expected.add(ax2)
        p.below.append(ax2)
        self.assertEqual(set(plt.axis()), expected)

        ax3 = LinearAxis()
        expected.add(ax3)
        p.left.append(ax3)
        self.assertEqual(set(plt.axis()), expected)

        ax4 = LinearAxis()
        expected.add(ax4)
        p.right.append(ax4)
        self.assertEqual(set(plt.axis()), expected)
Exemple #19
0
 def make_plots(self, ticker1, ticker2):
     self.plot = circle(ticker1 + "_returns", ticker2 + "_returns",
                        title="%s vs %s" %(ticker1, ticker2),
                        source=self.source,
                        plot_width=400, plot_height=400,
                        tools="pan,wheel_zoom,select"
     )
Exemple #20
0
    def test_axis(self):
        plt.figure()
        p = plt.circle([1,2,3], [1,2,3])
        self.assertEqual(len(plt.axis()), 2)

        expected = set(plt.axis())

        ax = LinearAxis()
        expected.add(ax)
        p.above.append(ax)
        self.assertEqual(set(plt.axis()), expected)

        ax2 = LinearAxis()
        expected.add(ax2)
        p.below.append(ax2)
        self.assertEqual(set(plt.axis()), expected)

        ax3 = LinearAxis()
        expected.add(ax3)
        p.left.append(ax3)
        self.assertEqual(set(plt.axis()), expected)

        ax4 = LinearAxis()
        expected.add(ax4)
        p.right.append(ax4)
        self.assertEqual(set(plt.axis()), expected)
Exemple #21
0
 def test_add(self):
     d = document.Document()
     p = circle([1], [2])
     d.add(p)
     self.assertListEqual(d.context.children, [p])
     self.assertEqual(len(d._models), len(p.references())+1)
     self.assertTrue(d.context._dirty)
Exemple #22
0
 def make_plots(self, ticker1, ticker2):
     self.plot = circle(ticker1 + "_returns",
                        ticker2 + "_returns",
                        title="%s vs %s" % (ticker1, ticker2),
                        source=self.source,
                        plot_width=400,
                        plot_height=400,
                        tools="pan,wheel_zoom,select")
Exemple #23
0
 def make_plots(self, ticker1, ticker2):
     self.plot = circle(ticker1 + "_returns", ticker2 + "_returns", 
                        title="%s vs %s" %(ticker1, ticker2),
                        source=self.source,
                        plot_width=400, plot_height=400,
                        tools="pan,wheel_zoom,select"
     )
     session().plotcontext.children=[self]
     session().plotcontext._dirty = True
Exemple #24
0
def bokeh_highlights(s_vectors,
                     n=1,
                     color='#DF4949',
                     swap_xy=True,
                     radius=2.5,
                     alpha=0.5):
    """n is the number of effect per cell to pick"""
    xv, yv = zip(*s_vectors)
    if swap_xy:
        xv, yv = yv, xv
    plotting.circle(xv,
                    yv,
                    fill_color=None,
                    line_color=color,
                    line_alpha=alpha,
                    line_width=0.5,
                    radius=radius,
                    radius_units='screen')
Exemple #25
0
def build_scatter_tooltip(x, y, tt, add_line=True, radius=3, title='My Plot',
                          xlabel='Iteration number', ylabel='Score'):
    bk.figure(title=title)
    bk.hold()
    bk.circle(
        x, y, radius=radius, source=ColumnDataSource(tt),
        fill_alpha=0.6, line_color=None, tools=TOOLS)

    if add_line:
        bk.line(x, y, line_width=2)

    xax, yax = bk.axis()
    xax.axis_label = xlabel
    yax.axis_label = ylabel

    cp = bk.curplot()
    hover = cp.select(dict(type=HoverTool))
    format_tt = [(s, '@%s' % s) for s in tt.columns]
    hover.tooltips = OrderedDict([("index", "$index")] + format_tt)
Exemple #26
0
 def make_plots(self, ticker1, ticker2):
     self.plot = circle(ticker1 + "_returns",
                        ticker2 + "_returns",
                        title="%s vs %s" % (ticker1, ticker2),
                        source=self.source,
                        plot_width=400,
                        plot_height=400,
                        tools="pan,wheel_zoom,select")
     session().plotcontext.children = [self]
     session().plotcontext._dirty = True
Exemple #27
0
def make_plot():
    sess = session()
    data = pd.DataFrame({'a'  : np.random.randn(100), 'b' : np.random.randn(100)})
    source = ColumnDataSource(data=data)
    scatter_plot = circle(source=source, x='a', y='b', plot_width=500, 
                         plot_height=500)
    app = App(data_source=source,
              scatter_plot=scatter_plot,
              stats=str(data.describe())
    )
    return app
 def line_plot(self, ticker, x_range=None):
     plot = circle('date', ticker,
                   title=ticker,
                   size=2,
                   x_range=x_range,
                   x_axis_type='datetime',
                   source=self.source,
                   title_text_font_size="10pt",
                   plot_width=1000, plot_height=200,
                   nonselection_alpha=0.02,
                   tools="pan,wheel_zoom,select")
     return plot
Exemple #29
0
def make_plot():
    sess = session()
    data = pd.DataFrame({'a': np.random.randn(100), 'b': np.random.randn(100)})
    source = ColumnDataSource(data=data)
    scatter_plot = circle(source=source,
                          x='a',
                          y='b',
                          plot_width=500,
                          plot_height=500)
    app = App(data_source=source,
              scatter_plot=scatter_plot,
              stats=str(data.describe()))
    return app
Exemple #30
0
 def line_plot(self, ticker, x_range=None):
     plot = circle(
         'date', ticker,
         title=ticker,
         size=2,
         x_range=x_range,
         x_axis_type='datetime',
         source=self.source,
         title_text_font_size="10pt",
         plot_width=1000, plot_height=200,
         nonselection_alpha=0.02,
         tools="pan,wheel_zoom,select"
     )
     return plot
 def make_plots(self):
     ticker1 = self.ticker1
     ticker2 = self.ticker2
     self.plot = circle(ticker1 + "_returns", ticker2 + "_returns",
                        size=2,
                        title="%s vs %s" %(ticker1, ticker2),
                        source=self.source,
                        plot_width=400, plot_height=400,
                        tools="pan,wheel_zoom,select",
                        title_text_font_size="10pt",
                        nonselection_alpha=0.02
     )
     self.line_plot1 = self.line_plot(ticker1)
     self.line_plot2 = self.line_plot(ticker2, self.line_plot1.x_range)
     self.hist_plots()
Exemple #32
0
def posture_signals(kin_env,
                    m_signals,
                    title='posture graphs',
                    color='#666666',
                    alpha=1.0,
                    radius_factor=1.0,
                    swap_xy=True,
                    x_range=[-1.0, 1.0],
                    y_range=[-1.0, 1.0],
                    **kwargs):

    for m_signal in m_signals:
        m_vector = kin_env.flatten_synergies(m_signal)
        s_signal = kin_env._multiarm.forward_kin(m_vector)

        xs, ys = [0.0], [0.0]
        for i in range(kin_env.cfg.dim):
            xs.append(s_signal['x{}'.format(i + 1)])
            ys.append(s_signal['y{}'.format(i + 1)])

        if isinstance(kin_env.cfg.lengths, numbers.Real):
            total_length = kin_env.cfg.lengths * kin_env.cfg.dim
        else:
            total_length = sum(kin_env.cfg.lengths)
        total_length += 0.0

        kwargs.update({
            'x_range': x_range,
            'y_range': y_range,
            'line_color': color,
            'line_alpha': alpha,
            'fill_color': color,
            'fill_alpha': alpha,
            'title': title
        })

        if swap_xy:
            xs, ys = ys, xs

        plotting.line(xs, ys, line_width=2.0 * radius_factor, **kwargs)
        plotting.hold(True)
        plotting.grid().grid_line_color = None
        plotting.ygrid().grid_line_color = None
        plotting_axis()

        plotting.circle(xs[:1], ys[:1], radius=radius_factor * 0.015, **kwargs)
        plotting.circle(xs[1:-1],
                        ys[1:-1],
                        radius=radius_factor * 0.008,
                        **kwargs)
        plotting.circle(xs[-1:],
                        ys[-1:],
                        radius=radius_factor * 0.01,
                        color='red',
                        alpha=alpha)
    plotting.hold(False)
Exemple #33
0
 def make_plots(self):
     ticker1 = self.ticker1
     ticker2 = self.ticker2
     self.plot = circle(
         ticker1 + "_returns", ticker2 + "_returns",
         size=2,
         title="%s vs %s" %(ticker1, ticker2),
         source=self.source,
         plot_width=400, plot_height=400,
         tools="pan,wheel_zoom,select",
         title_text_font_size="10pt",
         nonselection_alpha=0.02,
     )
     self.line_plot1 = self.line_plot(ticker1)
     self.line_plot2 = self.line_plot(ticker2, self.line_plot1.x_range)
     self.hist_plots()
Exemple #34
0
def posture_signals(
    kin_env,
    m_signals,
    title="posture graphs",
    color="#666666",
    alpha=1.0,
    radius_factor=1.0,
    swap_xy=True,
    x_range=[-1.0, 1.0],
    y_range=[-1.0, 1.0],
    **kwargs
):

    for m_signal in m_signals:
        m_vector = kin_env.flatten_synergies(m_signal)
        s_signal = kin_env._multiarm.forward_kin(m_vector)

        xs, ys = [0.0], [0.0]
        for i in range(kin_env.cfg.dim):
            xs.append(s_signal["x{}".format(i + 1)])
            ys.append(s_signal["y{}".format(i + 1)])

        if isinstance(kin_env.cfg.lengths, numbers.Real):
            total_length = kin_env.cfg.lengths * kin_env.cfg.dim
        else:
            total_length = sum(kin_env.cfg.lengths)
        total_length += 0.0

        kwargs.update(
            {
                "x_range": x_range,
                "y_range": y_range,
                "line_color": color,
                "line_alpha": alpha,
                "fill_color": color,
                "fill_alpha": alpha,
                "title": title,
            }
        )

        if swap_xy:
            xs, ys = ys, xs

        plotting.line(xs, ys, line_width=2.0 * radius_factor, **kwargs)
        plotting.hold(True)
        plotting.grid().grid_line_color = None
        plotting.ygrid().grid_line_color = None
        plotting_axis()

        plotting.circle(xs[:1], ys[:1], radius=radius_factor * 0.015, **kwargs)
        plotting.circle(xs[1:-1], ys[1:-1], radius=radius_factor * 0.008, **kwargs)
        plotting.circle(xs[-1:], ys[-1:], radius=radius_factor * 0.01, color="red", alpha=alpha)
    plotting.hold(False)
Exemple #35
0
    def test_xaxis(self):
        plt.figure()
        p = plt.circle([1,2,3], [1,2,3])
        self.assertEqual(len(plt.xaxis()), 1)

        expected = set(plt.xaxis())

        ax = LinearAxis()
        expected.add(ax)
        p.above.append(ax)
        self.assertEqual(set(plt.xaxis()), expected)

        ax2 = LinearAxis()
        expected.add(ax2)
        p.above.append(ax2)
        self.assertEqual(set(plt.xaxis()), expected)

        p.left.append(LinearAxis())
        self.assertEqual(set(plt.xaxis()), expected)

        p.right.append(LinearAxis())
        self.assertEqual(set(plt.xaxis()), expected)
Exemple #36
0
    def test_xaxis(self):
        plt.figure()
        p = plt.circle([1,2,3], [1,2,3])
        self.assertEqual(len(plt.xaxis()), 1)

        expected = set(plt.xaxis())

        ax = LinearAxis()
        expected.add(ax)
        p.above.append(ax)
        self.assertEqual(set(plt.xaxis()), expected)

        ax2 = LinearAxis()
        expected.add(ax2)
        p.above.append(ax2)
        self.assertEqual(set(plt.xaxis()), expected)

        p.left.append(LinearAxis())
        self.assertEqual(set(plt.xaxis()), expected)

        p.right.append(LinearAxis())
        self.assertEqual(set(plt.xaxis()), expected)
Exemple #37
0
def bokeh_kin(kin_env, m_signal, color='#DF4949', alpha=1.0, **kwargs):

    m_vector = tools.to_vector(m_signal, kin_env.m_channels)
    s_signal = kin_env._multiarm.forward_kin(m_vector)

    xs, ys = [0.0], [0.0]
    for i in range(kin_env.cfg.dim):
        xs.append(s_signal['x{}'.format(i + 1)])
        ys.append(s_signal['y{}'.format(i + 1)])
    xs, ys = ys, xs  # we swap x and y for a more symmetrical look

    if isinstance(kin_env.cfg.lengths, numbers.Real):
        total_length = kin_env.cfg.lengths * kin_env.cfg.dim
    else:
        total_length = sum(kin_env.cfg.lengths)
    total_length += 0.0

    kwargs = {
        'plot_height': int(350 * 1.60),
        'plot_width': int(350 * 1.60),
        'x_range': [-1.0, 1.0],
        'y_range': [-1.0, 1.0],
        'line_color': color,
        'line_alpha': alpha,
        'fill_color': color,
        'fill_alpha': alpha,
        'title': ''
    }

    plotting.hold()
    plotting.line(xs, ys, **kwargs)
    plotting.grid().grid_line_color = None
    plotting.xaxis().major_tick_in = 0
    plotting.ygrid().grid_line_color = None
    plotting.yaxis().major_tick_in = 0

    plotting.circle(xs[:1], ys[:1], radius=0.015, **kwargs)
    plotting.circle(xs[1:-1], ys[1:-1], radius=0.008, **kwargs)
    plotting.circle(xs[-1:], ys[-1:], radius=0.01, color='red')
    plotting.hold(False)
Exemple #38
0
def bokeh_kin(kin_env, m_signal, color='#DF4949', alpha=1.0, **kwargs):

    m_vector = tools.to_vector(m_signal, kin_env.m_channels)
    s_signal = kin_env._multiarm.forward_kin(m_vector)

    xs, ys = [0.0], [0.0]
    for i in range(kin_env.cfg.dim):
        xs.append(s_signal['x{}'.format(i+1)])
        ys.append(s_signal['y{}'.format(i+1)])
    xs, ys = ys, xs # we swap x and y for a more symmetrical look

    if isinstance(kin_env.cfg.lengths, numbers.Real):
        total_length = kin_env.cfg.lengths*kin_env.cfg.dim
    else:
        total_length = sum(kin_env.cfg.lengths)
    total_length += 0.0

    kwargs ={'plot_height' : int(350*1.60),
             'plot_width'  : int(350*1.60),
             'x_range'     : [-1.0, 1.0],
             'y_range'     : [-1.0, 1.0],
             'line_color'  : color,
             'line_alpha'  : alpha,
             'fill_color'  : color,
             'fill_alpha'  : alpha,
             'title':''
            }

    plotting.hold()
    plotting.line(xs, ys, **kwargs)
    plotting.grid().grid_line_color = None
    plotting.xaxis().major_tick_in   = 0
    plotting.ygrid().grid_line_color = None
    plotting.yaxis().major_tick_in   = 0

    plotting.circle(xs[  : 1], ys[  : 1], radius=0.015, **kwargs)
    plotting.circle(xs[ 1:-1], ys[ 1:-1], radius=0.008, **kwargs)
    plotting.circle(xs[-1:  ], ys[-1:  ], radius=0.01, color='red')
    plotting.hold(False)
Exemple #39
0
        if yvkey:
          all_yv.append( sdata["stats"][yvkey] )

      ### check for data
      if not len(all_y):
        continue

      fig = bplt.figure()
      bplt.hold()

      ### build data source for hover tool
      source = bplt.ColumnDataSource(data=dict(x=all_x, y=all_y, stefilename=all_stefilename, Nmodes=all_Nmodes, Ngens=all_Ngens, Ntriples=all_Ntriples))

      ### plot circle glyphs
      bplt.circle(all_x, all_y, source=source, tools=TOOLS, fill_color=None, fill_alpha=0.6, line_color=all_color, Title="%s vs %s"%(xlabel,  ylabel), plot_width=plot_width, plot_height=plot_height)
#      bplt.circle(all_x, all_y, radius=radii, source=source, tools=TOOLS, fill_color=None, fill_alpha=0.6, line_color=all_color, Title="%s vs %s"%(xlabel,  ylabel))

      ### annotate circle glyphs
#      text(x, y, text=inds, alpha=0.5, text_font_size="5pt", text_baseline="middle", text_align="center", angle=0)

      ### find hover tool, and tell it what to look for
      hover = [t for t in bplt.curplot().tools if isinstance(t, HoverTool)][0]
      hover.tooltips = OrderedDict([ 
                                    #("index", "$index"), 
                                    ("(x,y)", "($x, $y)"),
                                    ("stefilename", "@stefilename"),
                                    ("Nmodes","@Nmodes"),
                                    ("Ntriples","@Ntriples"),
                                    ("Ngens","@Ngens"),
                                   ])
Exemple #40
0
 def test_grid(self):
     plt.figure()
     p = plt.circle([1,2,3], [1,2,3])
     self.assertEqual(len(plt.grid()), 2)
Exemple #41
0
 def test_ygrid(self):
     plt.figure()
     p = plt.circle([1,2,3], [1,2,3])
     self.assertEqual(len(plt.ygrid()), 1)
     self.assertEqual(plt.ygrid()[0].dimension, 1)
Exemple #42
0
def setUpModule():
    global _embed_test_plot
    _embed_test_plot = circle([1,2], [2,3])
def setUpModule():
    global _embed_test_plot
    _embed_test_plot = circle([1,2], [2,3])
Exemple #44
0
 def test_ygrid(self):
     plt.figure()
     p = plt.circle([1,2,3], [1,2,3])
     self.assertEqual(len(plt.ygrid()), 1)
     self.assertEqual(plt.ygrid()[0].dimension, 1)
Exemple #45
0
 def test_grid(self):
     plt.figure()
     p = plt.circle([1,2,3], [1,2,3])
     self.assertEqual(len(plt.grid()), 2)
Exemple #46
0
        ex_cfg.m_channels = env.m_channels
        ex_cfg.s_channels = env.s_channels
        ex = explorers.Explorer.create(ex_cfg)

        # running the exploration
        explorations, s_vectors, s_goals = factored.run_exploration(env, ex, N)

        # making graphs
        radius, alpha = 1.0, 0.35
        if ex_name == 'distrib_corner':
            radius, alpha = 0.75, 0.15

        plotting.circle([0.0], [0.0],
                        radius=1.0,
                        x_range=(-xy_range, xy_range),
                        y_range=(-xy_range, xy_range),
                        fill_color='#000000',
                        fill_alpha=0.075,
                        line_color=None,
                        title='goal distribution for {}'.format(ex_name))
        graphs.hold(True)
        graphs.spread(ex.s_channels,
                      s_vectors=(),
                      s_goals=s_goals,
                      g_radius=radius,
                      g_alpha=alpha,
                      grid=None,
                      title='{} goals'.format(ex_name))

        graphs.spread(ex.s_channels,
                      s_vectors=s_vectors,
                      s_goals=(),