• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python plugins.connect函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mpld3.plugins.connect函数的典型用法代码示例。如果您正苦于以下问题:Python connect函数的具体用法?Python connect怎么用?Python connect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了connect函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: main

def main():
    fig, ax = plt.subplots()
    points = ax.plot(range(10), 'o', ms=20)
    plugins.connect(fig, plugins.PointLabelTooltip(points[0],
                                                   location="top left"))

    return fig
开发者ID:Ahmed,项目名称:mpld3,代码行数:7,代码来源:test_plot_w_tooltips.py


示例2: main

def main():
    fig, ax = plt.subplots()
    line, = ax.plot([0, 1, 3, 8, 5], '-', lw=5)
    plugins.connect(fig, plugins.LineLabelTooltip(line, 'Line A'))
    ax.set_title('Line with Tooltip')

    return fig
开发者ID:JuergenNeubauer,项目名称:mpld3,代码行数:7,代码来源:test_plot_w_line_tooltips.py


示例3: main

def main():
    fig, ax = plt.subplots(2)

    # scatter periods and amplitudes
    np.random.seed(0)
    P = 0.2 + np.random.random(size=20)
    A = np.random.random(size=20)
    x = np.linspace(0, 10, 100)
    data = np.array([[x, Ai * np.sin(x / Pi)]
                     for (Ai, Pi) in zip(A, P)])
    points = ax[1].scatter(P, A, c=P + A,
                           s=200, alpha=0.5)
    ax[1].set_xlabel('Period')
    ax[1].set_ylabel('Amplitude')

    # create the line object
    lines = ax[0].plot(x, 0 * x, '-w', lw=3, alpha=0.5)
    ax[0].set_ylim(-1, 1)

    ax[0].set_title("Hover over points to see lines")

    # transpose line data and add plugin
    linedata = data.transpose(0, 2, 1).tolist()
    plugins.connect(fig, LinkedView(points, lines[0], linedata))

    return fig
开发者ID:JuergenNeubauer,项目名称:mpld3,代码行数:26,代码来源:test_custom_plugin.py


示例4: plot_snr_cmd

    def plot_snr_cmd(self, snr, ax, color='bv', mag='v', add_candidates=True):
        cmd_search = self.session.query(malchemy.MCPS).\
            join(malchemy.SNRNeighbour).join(malchemy.SNRS).\
            filter(malchemy.SNRS.id==snr.snr.id)

        cmd_data = [(item.__getattribute__(color[0]) -
                     item.__getattribute__(color[1]),
                     item.__getattribute__(mag)) for item in cmd_search]
        data = np.array(cmd_data)
        H, xedges, yedges = np.histogram2d(data[:,1], data[:,0], bins=100,
                                           range=[[16,22],[-1,2]])
        extent = [yedges[0], yedges[-1], xedges[-1], xedges[0]]
        ax.imshow(H, extent=extent, interpolation='nearest',
                  cmap=cm.gray_r,
                  aspect='auto')

        ax.set_xlabel('Color {0} - {1}'.format(*list(color)))
        ax.set_ylabel('mag {0}'.format(mag))

        if add_candidates:
            candidate_coord = [(item.mcps.__getattribute__(color[0]) -
                     item.mcps.__getattribute__(color[1]),
                     item.mcps.__getattribute__(mag)) for item in snr.candidates]

            candidate_coord = np.array(candidate_coord)
            cand_plot = ax.plot(candidate_coord[:,0], candidate_coord[:,1], 'bo')
            cand_labels = [str(item) for item in snr.candidates]
            tooltip = plugins.PointHTMLTooltip(cand_plot[0], cand_labels,
                                   voffset=10, hoffset=10)

            plugins.connect(ax.figure, tooltip)



        return cand_plot
开发者ID:mhvk,项目名称:mcsnr,代码行数:35,代码来源:mcsnr_project.py


示例5: plot_xy_bootstrapped

def plot_xy_bootstrapped(xs, ys, thresholds, xlabel, ylabel, labels=False, labels_left=False, ax=None, fig=None, label=None, **plot_kwargs):
    if ax is None or fig is None:
        fig1, ax1 = plt.subplots()
    if fig is None:
        fig = fig1
    if ax is None:
        ax = ax1
    for i in range(1, len(xs)):
        ax.plot(xs[i], ys[i], '-', alpha=0.3)
    (xs_, ys_, thresholds_) = make_points_far(xs[0], ys[0], thresholds)
    label_text = ["Threshold: %s (%s, %s)" % (t, pretty_point(x), pretty_point(y)) for (x, y, t) in zip(xs_, ys_, thresholds_)]
    if label is None:
        scatter = ax.plot(xs_, ys_, '-o', **plot_kwargs)
        plugins.connect(fig, plugins.PointHTMLTooltip(scatter[0], label_text))
    else:
        scatter = ax.plot(xs_, ys_, '-o', label=label, **plot_kwargs)
        plugins.connect(fig, plugins.PointHTMLTooltip(scatter[0], label_text))
    if labels:
        draw_labels(ax, xs_, ys_, thresholds_, labels_left=labels_left)
    plt.xlim(0, 1)
    plt.ylim(0, 1)
    plt.xlabel(xlabel)
    plt.ylabel(ylabel)
    plt.tight_layout()
    if label is not None:
        handles, labels = ax.get_legend_handles_labels()
        ax.legend(handles[::-1], labels[::-1], loc='best')
    return save_image()
开发者ID:ryninho,项目名称:topmodel,代码行数:28,代码来源:plot_helpers.py


示例6: generate_embedding

def generate_embedding(param_file, model_file, mnist_file, output_file=None,
                       param_key=None):
    predictor = optimus.load(model_file)
    params = biggie.Stash(param_file)
    param_key = sorted(params.keys())[-1] if param_key is None else param_key
    predictor.param_values = params.get(param_key)

    train, valid, test = datatools.load_mnist_npz(mnist_file)
    idx = np.random.permutation(len(valid[0]))[:2000]
    x_in = valid[0][idx]
    y_true = valid[1][idx]
    z_out = predictor(x_in=x_in)['z_out']

    imgfiles = [datatools.generate_imagename(i, y)
                for i, y in enumerate(idx, y_true)]

    labels = ['<img src="{}{}" width=100 height=100>'.format(URL_BASE, img)
              for img in imgfiles]

    palette = seaborn.color_palette("Set3", 10)
    colors = np.asarray([palette[y] for y in y_true])
    fig = plt.figure(figsize=(10, 10))
    ax = fig.gca()
    handle = ax.scatter(z_out.T[0], z_out.T[1],
                        c=colors, s=75, alpha=0.66)

    tooltip = plugins.PointHTMLTooltip(
        handle, labels,
        voffset=10, hoffset=10)

    plugins.connect(fig, tooltip)
    plt.show()
    if output_file:
        with open(output_file, 'w') as fp:
            mpld3.save_html(fig, fp)
开发者ID:ejhumphrey,项目名称:mnistifolds,代码行数:35,代码来源:visualize.py


示例7: create_plot

def create_plot():
    fig, ax = plt.subplots()
    line, = ax.plot([0, 1, 3, 8, 5], '-', lw=5)
    label = '<h1>Line {}</h1>'.format('A')
    plugins.connect(fig, plugins.LineHTMLTooltip(line, label))
    ax.set_title('Line with HTML Tooltip')
    return fig
开发者ID:2ciyuan,项目名称:mpld3,代码行数:7,代码来源:test_line_HTMLtooltips.py


示例8: doRender

    def doRender(self, handlerId):
        if self.canRenderChart(handlerId) == False:
            self._addHTML("Unable to find a numerical column in the dataframe")
            return

        mpld3.enable_notebook()
        fig, ax = plt.subplots()
        keyFields = self.getKeyFields(handlerId)
        keyFieldValues = self.getKeyFieldValues(handlerId, keyFields)
        keyFieldLabels = self.getKeyFieldLabels(handlerId, keyFields)
        valueFields = self.getValueFields(handlerId)
        valueFieldValues = self.getValueFieldValueLists(handlerId, keyFields, valueFields)
        context = self.getMpld3Context(handlerId)
        options = {"fieldNames":self.getFieldNames(),"aggregationSupported":self.supportsAggregation(handlerId),"aggregationOptions":["SUM","AVG","MIN","MAX","COUNT"]}
        if (context is not None):
            options.update(context[1])
            dialogBody = self.renderTemplate(context[0], **options)
        else:
            dialogBody = self.renderTemplate("baseChartOptionsDialogBody.html", **options)
        plugins.connect(fig, ChartPlugin(self, keyFieldLabels))
        plugins.connect(fig, DialogPlugin(self, handlerId, dialogBody))
        self.doRenderMpld3(handlerId, fig, ax, keyFields, keyFieldValues, keyFieldLabels, valueFields, valueFieldValues)
        self.setChartSize(handlerId, fig, ax)
        self.setChartGrid(handlerId, fig, ax)
        self.setChartLegend(handlerId, fig, ax)
开发者ID:ygoverdhan,项目名称:pixiedust,代码行数:25,代码来源:mpld3ChartDisplay.py


示例9: plot

    def plot(self, notebook=False, colormap='polar', scale=1, maptype='points', show=True, savename=None):

        # make a spatial map based on the scores
        fig = pyplot.figure(figsize=(12, 5))
        ax1 = pyplot.subplot2grid((2, 3), (0, 1), colspan=2, rowspan=2)
        if maptype is 'points':
            ax1, h1 = pointmap(self.scores, colormap=colormap, scale=scale, ax=ax1)
        elif maptype is 'image':
            ax1, h1 = imagemap(self.scores, colormap=colormap, scale=scale, ax=ax1)
        fig.add_axes(ax1)

        # make a scatter plot of sampled scores
        ax2 = pyplot.subplot2grid((2, 3), (1, 0))
        ax2, h2, samples = scatter(self.scores, colormap=colormap, scale=scale, thresh=0.01, nsamples=1000, ax=ax2, store=True)
        fig.add_axes(ax2)

        # make the line plot of reconstructions from principal components for the same samples
        ax3 = pyplot.subplot2grid((2, 3), (0, 0))
        ax3, h3, linedata = tsrecon(self.comps, samples, ax=ax3)

        plugins.connect(fig, LinkedView(h2, h3[0], linedata))
        plugins.connect(fig, HiddenAxes())

        if show and notebook is False:
            mpld3.show()

        if savename is not None:
            mpld3.save_html(fig, savename)
        elif show is False:
            return mpld3.fig_to_html(fig)
开发者ID:mathisonian,项目名称:thunder,代码行数:30,代码来源:pca.py


示例10: main

def main():
    fig, ax = plt.subplots()

    N = 50
    df = pd.DataFrame(index=range(N))
    df['x'] = np.random.randn(N)
    df['y'] = np.random.randn(N)
    df['z'] = np.random.randn(N)

    labels = []
    for i in range(N):
        label = df.ix[[i], :].T
        label.columns = ['Row {0}'.format(i)]
        labels.append(str(label.to_html()))  # .to_html() is unicode, so make leading 'u' go away with str()

    points = ax.plot(df.x, df.y, 'o', color='k', mec='w', ms=15, mew=1, alpha=.9)

    ax.set_xlabel('x')
    ax.set_ylabel('y')

    tooltip = plugins.PointHTMLTooltip(
        points[0], labels, voffset=10, hoffset=10, css=css)
    plugins.connect(fig, tooltip)

    return fig
开发者ID:JuergenNeubauer,项目名称:mpld3,代码行数:25,代码来源:test_plot_w_html_tooltips.py


示例11: plot

    def plot(self, data, notebook=False, show=True, savename=None):

        fig = pyplot.figure()
        ncenters = len(self.centers)

        colorizer = Colorize()
        colorizer.get = lambda x: self.colors[int(self.predict(x)[0])]

        # plot time series of each center
        # TODO move into a time series plotting function in viz.plots
        for i, center in enumerate(self.centers):
            ax = pyplot.subplot2grid((ncenters, 3), (i, 0))
            ax.plot(center, color=self.colors[i], linewidth=5)
            fig.add_axes(ax)

        # make a scatter plot of the data
        ax2 = pyplot.subplot2grid((ncenters, 3), (0, 1), rowspan=ncenters, colspan=2)
        ax2, h2 = scatter(data, colormap=colorizer, ax=ax2)
        fig.add_axes(ax2)

        plugins.connect(fig, HiddenAxes())

        if show and notebook is False:
            mpld3.show()

        if savename is not None:
            mpld3.save_html(fig, savename)

        elif show is False:
            return mpld3.fig_to_html(fig)
开发者ID:uklibaite,项目名称:thunder,代码行数:30,代码来源:kmeans.py


示例12: __call__

    def __call__(self, plot, view):
        if not self._applies(plot, view): return
        fig = plot.handles['fig']
        if 'legend' in plot.handles:
            plot.handles['legend'].set_visible(False)
        line_segments, labels = [], []
        keys = view.keys()
        for idx, subplot in enumerate(plot.subplots.values()):
            if isinstance(subplot, PointPlot):
                line_segments.append(subplot.handles['paths'])
                if isinstance(view, NdOverlay):
                    labels.append(str(keys[idx]))
                else:
                    labels.append(subplot.map.last.label)
            elif isinstance(subplot, CurvePlot):
                line_segments.append(subplot.handles['line_segment'])
                if isinstance(view, NdOverlay):
                    labels.append(str(keys[idx]))
                else:
                    labels.append(subplot.map.last.label)

        tooltip = plugins.InteractiveLegendPlugin(line_segments, labels,
                                                  alpha_sel=self.alpha_sel,
                                                  alpha_unsel=self.alpha_unsel)
        plugins.connect(fig, tooltip)
开发者ID:aashish24,项目名称:holoviews,代码行数:25,代码来源:hooks.py


示例13: create_plot

def create_plot():
    fig, ax = plt.subplots()
    points = ax.scatter(np.random.rand(50), np.random.rand(50),
                        s=500, alpha=0.3)

    plugins.clear(fig)
    plugins.connect(fig, plugins.Reset(), plugins.Zoom(), ClickInfo(points))
    return fig
开发者ID:Bantalik,项目名称:mpld3,代码行数:8,代码来源:test_mouse_events.py


示例14: after

 def after(self):
     if self.draw:
         plugins.connect(
             self.fig, plugins.InteractiveLegendPlugin(
                 self.s1, self.labels, ax=self.ax))
         mpld3.show()
     else:
         pass
开发者ID:ssh0,项目名称:sotsuron,代码行数:8,代码来源:simple3.py


示例15: after

 def after(self):
     if self.draw:
         plugins.connect(
             self.fig, plugins.InteractiveLegendPlugin(
                 self.s1, self.labels, ax=self.ax))
         mpld3.display()
     else:
         print meeting.minutes
开发者ID:ssh0,项目名称:sotsuron,代码行数:8,代码来源:simple3_45.py


示例16: plot_ts

def plot_ts(*args, **kwargs):
    """ Create an interactive JavaScript T-S plot. """
    ax = nplt.plot_ts(*args, **kwargs)
    pg = InteractiveLegendPlugin(ax.lines,
            kwargs.get("labels", [lin.get_label() for lin in ax.lines]),
            alpha_unsel=kwargs.get("alpha", 0.2))
    plugins.connect(ax.figure, pg)
    mpld3.display()
    return ax
开发者ID:arnaldorusso,项目名称:narwhal,代码行数:9,代码来源:interactive_plotting.py


示例17: doRenderChart

    def doRenderChart(self):
        self.colormap = cm.jet

        # set defaults for plot
        plt.rcParams['savefig.dpi'] = 96
        plt.rcParams['font.family'] = "serif"
        plt.rcParams['font.serif'] = "cm"
        
        fig = None
        try:
            # go
            fig, ax = self.createFigure()

            if self.useMpld3:
                #TODO: rework this piece
                #keyFieldLabels = self.getKeyFieldLabels()
                #if (len(keyFieldLabels) > 0 and self.supportsKeyFieldLabels(self.handlerId) and self.supportsAggregation(self.handlerId)):
                #    plugins.connect(fig, ChartPlugin(self, keyFieldLabels))
                plugins.connect(fig, DialogPlugin(self, self.handlerId, self.dialogBody))

            #let subclass do the actual rendering
            newAx = self.matplotlibRender(fig, ax)
            if newAx is not None:
                ax = newAx

            axes = ax
            if not isinstance(axes, (list,np.ndarray)):
                axes = np.asarray([axes])

            #finalize the chart
            for i, a in np.ndenumerate(axes):
                if a.title is None or not a.title.get_visible() or a.title.get_text() == '':
                    self.setLegend(fig, a)
                self.setTicks(fig, a)
            sharex = True if len(axes) <=1 else len([a for a in axes if a._sharex is not None]) > 0
            if len(axes)>1 and not sharex:
                #adjust the height between subplots
                plt.subplots_adjust(hspace=self.getSubplotHSpace())

            #mpld3 has a bug when autolocator are used. Change to FixedLocators
            if self.useMpld3:
                self.addMessage("Warning: While great, D3 rendering is using MPLD3 library which has limitations that have not yet been fixed")
                from matplotlib import ticker
                self.debug("Converting to FixedLocator for mpld3")
                for a in axes:
                    locator = a.xaxis.get_major_locator()
                    if not isinstance(locator, ticker.FixedLocator):
                        vmin,vmax = a.xaxis.get_data_interval()
                        a.xaxis.set_major_locator(ticker.FixedLocator(locator.tick_values(vmin, vmax)))

            #Render the figure
            return self.renderFigure(fig)
        finally:
            if fig is not None:
                plt.close(fig)
开发者ID:ibm-cds-labs,项目名称:pixiedust,代码行数:55,代码来源:matplotlibBaseDisplay.py


示例18: main

def main():
    fig, ax = plt.subplots()
    xx = np.arange(12)
    yy = [3,1,4,1,5,9,2,6,5,3,5,9]

    ax.plot(xx, yy, 'ks-', ms=10, mec='w', mew=3)

    ax.set_title('Reset Button Test', size=14)

    plugins.connect(fig, plugins.ResetButton())
    return fig
开发者ID:JuergenNeubauer,项目名称:mpld3,代码行数:11,代码来源:test_reset_button.py


示例19: main

def main():
    fig, ax = plt.subplots(2, 2, sharex='col', sharey='row')

    X = np.random.normal(0, 1, (2, 100))

    for i in range(2):
        for j in range(2):
            points = ax[1 - i, j].scatter(X[i], X[j])

    plugins.connect(fig, plugins.LinkedBrush(points))
    return fig
开发者ID:agamdua,项目名称:mpld3,代码行数:11,代码来源:test_linkedbrush.py


示例20: main

def main():
    fig, ax = plt.subplots()
    colors = plt.rcParams['axes.color_cycle']
    points = []                    
    for i, color in enumerate(colors):
        points = ax.plot(i, 0, 'o', c=color)
        plugins.connect(fig,
                        plugins.PointLabelTooltip(points[0], [color]))
    ax.set_xlim(-1, len(colors) + 1)

    return fig
开发者ID:JuergenNeubauer,项目名称:mpld3,代码行数:11,代码来源:test_plot_w_tooltips_labels.py



注:本文中的mpld3.plugins.connect函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python mpldatacursor.datacursor函数代码示例发布时间:2022-05-27
下一篇:
Python mpld3.show函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap