How to use the mpld3.save_html function in mpld3

To help you get started, we’ve selected a few mpld3 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github HybriD3-database / MatD3 / materials / plotting / pl_plotting.py View on Github external
# print points[0]
    labels = []
    for i,j in zip(x,y):
        label = '<div class="tooltiptext">'
        label += '{2}: {1} <br> {3}: {0}'.format(i, j, y_label, x_label)
        label += '</div>'
        labels.append(label)

    tooltip = plugins.PointHTMLTooltip(points[0], labels, hoffset=-tooltipwidth/2, voffset=-tooltipheight, css=css)

    plugins.connect(fig, tooltip)

    save_name = "{}.html".format(filename.split(".")[0])
    # filename = "{}.png".format(filename.split(".")[0])
    # plt.savefig(filename, dpi = 300, bbox_inches='tight')
    mpld3.save_html(fig, save_name)
    plt.close()
    # mpld3.fig_to_html(plt_figure)
github ratschlab / spladder / matlab / spladder_viz.py View on Github external
event_info[1] = int(event_info[1]) - 1
            event_info = sp.array(event_info, dtype='str')[sp.newaxis, :]
            event_tag = '.%s' % options.event_id
        ### get all significant events of the current gene
        else:
            event_info = get_conf_events(options, gid)
            
        plot_event(options, event_info, axes[-1], xlim)

        plt.tight_layout()
        ### save plot into file
        if options.format == 'd3':
            out_fname = os.path.join(options.outdir, 'plots', 'gene_overview_%s%s%s.html' % (gene.name, event_tag, log_tag))
            plugins.clear(fig)
            plugins.connect(fig, plugins.Zoom(enabled=True), ClickInfo(sp.ones((10000,), dtype='int')))
            mpld3.save_html(fig, open(out_fname, 'w'))
        else:
            out_fname = os.path.join(options.outdir, 'plots', 'gene_overview_%s%s%s.%s' % (gene.name, event_tag, log_tag, options.format))
            plt.savefig(out_fname, format=options.format, bbox_inches='tight')
        plt.close(fig)
github AlJohri / OpenSubtitles / analyze.py View on Github external
ind = np.arange(len(innerDict.keys()))
        width = 0.35

        ax = fig.add_subplot(1,N_CLUSTERS+1,k+2)
        rects1 = ax.bar(ind, innerDict.values(), width, color='r')
        ax.set_xticklabels(innerDict.keys())
        print (innerDict.keys())

        blah.append(innerDict)

    print (blah)

    # plt.show()
    with open("output.html", 'w') as f:
        mpld3.save_html(fig, f)
    
    mpld3.show()
github alicevision / meshroom / meshroom / statistics.py View on Github external
return

    import matplotlib.pyplot as plt, mpld3

    fig = plt.figure()
    ax = fig.add_subplot(111, axisbg='#EEEEEE')
    ax.grid(color='white', linestyle='solid')

    for curveName, curve in curves:
        if not isinstance(curve[0], pg.basestring):
            ax.plot(curve, label=curveName)
    ax.legend()
    # plt.ylim(0, 100)
    plt.title(title)

    mpld3.save_html(fig, fileObj)
    plt.close(fig)
github commaai / openpilot / selfdrive / locationd / kalman / kalman_helpers.py View on Github external
ylim = max(np.linalg.norm(res[start_idx:], axis=1))
    ax.set_ylim([-ylim, ylim])
    if int(kind) in SAT_OBS:
      svIds = obs[kind]['svIds']
      for svId in set(svIds):
        svId_idx = (svIds == svId)
        t = obs[kind]['t'][svId_idx]
        res = obs[kind]['residual'][svId_idx]
        ax.plot(t, res, label='SV ' + str(int(svId)))
        ax.legend(loc='right')
    else:
      ax.plot(t, res)
    plt.title('Residual of kind ' + ObservationKind.to_string(int(kind)), fontsize=20)
  plt.tight_layout()
  os.makedirs(save_path)
  mpld3.save_html(fig, save_path + 'residuals_plot.html')
github ChairOfStructuralMechanicsTUM / Mechanics_Apps / WaveletApp / draft.py View on Github external
output = a[i]**-0.5 * amp * (t-b[j])/a[i] * exp(-( (t-b[j])/a[i] )**2.0)
            return output
        W[i][j]=quad(integrand1, 1, 3)[0]

fig, ax = plt.subplots()
im = ax.pcolormesh(a,b,W)
#plt.show()


fig.colorbar(im, ax=ax)
ax.set_title('An Image', size=20)


mpld3.fig_to_html(fig)
mpld3.show()
mpld3.save_html(fig, "Wavelet.html")
github pyrocko / grond / src / plot / config.py View on Github external
def render_mpl(self, fig, path, **kwargs):
        import mpld3
        kwargs.pop('dpi')

        mpld3.save_html(
            fig,
            fileobj=path,
            **kwargs)
github salilab / imp / modules / pmi / pyext / src / io / xltable.py View on Github external
sorted_keys=sorted(xl_list[0].keys())

        for k in sorted_keys:
            df[k] = np.array([xl[k] for xl in xl_list])

        labels = []
        for i in range(len(xl_labels)):
            label = df.ix[[i], :].T
            # .to_html() is unicode; so make leading 'u' go away with str()
            labels.append(str(label.to_html()))

        tooltip = plugins.PointHTMLTooltip(points, labels,
                                   voffset=10, hoffset=10, css=css)
        plugins.connect(fig, tooltip)
        mpld3.save_html(fig,"output.html")