當前位置: 首頁>>代碼示例>>Python>>正文


Python mpld3.fig_to_html方法代碼示例

本文整理匯總了Python中mpld3.fig_to_html方法的典型用法代碼示例。如果您正苦於以下問題:Python mpld3.fig_to_html方法的具體用法?Python mpld3.fig_to_html怎麽用?Python mpld3.fig_to_html使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在mpld3的用法示例。


在下文中一共展示了mpld3.fig_to_html方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: generate_2d_viz

# 需要導入模塊: import mpld3 [as 別名]
# 或者: from mpld3 import fig_to_html [as 別名]
def generate_2d_viz(self, study_names, embeddings_dict, words_dict, name):

        # create 1 x 3 grid of plots (one per PICO element)
        f, axes_array = plt.subplots(1, 3)#, figsize=(15,30))

        # iterate over three embeddings (P/I/O)
        for i, element in enumerate(self.elements):
            X_hat = self.PCA_dict[element].transform(embeddings_dict[element])

            cur_ax = axes_array[i]

            points, RGB_palette = scatter(study_names, X_hat, cur_ax, title=element.lower())

            # setup labels; color code consisent w/scatter
            labels = []
            for study_idx, study_words in enumerate(words_dict[element]):
                label_str = u"<p style='color:{0}'>".format(RGB_palette[study_idx])
                label_str +=  ", ".join(study_words) + "</p>"
                labels.append(label_str)

            tooltip = mpld3.plugins.PointHTMLTooltip(points, labels=labels)
            mpld3.plugins.connect(f, tooltip)

        return mpld3.fig_to_html(f) 
開發者ID:ijmarshall,項目名稱:robotreviewer,代碼行數:26,代碼來源:pico_viz_robot.py

示例2: index

# 需要導入模塊: import mpld3 [as 別名]
# 或者: from mpld3 import fig_to_html [as 別名]
def index():
    keys = [1,2,3,4]
    values = [1,4,2,3]

    plots = plt.bar(keys, values, width=0.5)

    plt.xlabel("Side Effects")
    plt.ylabel("Percentages of Occurence of Side Effects")
    plt.title("Bar Chart showing Side Effects of Breast \
Cancer Medication(s) With Their Corrresponding Percentages Of \
Occurence")
    #plt.legend()

    fig = plots[0].figure
    #ax = plots[0].axis
     
    plt_html = mpld3.fig_to_html(fig)

    return '''<DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>''' + plt_html + '''</body>
</html>''' 
開發者ID:furas,項目名稱:python-examples,代碼行數:27,代碼來源:main-mpld3.py

示例3: coinc_timeseries_plot

# 需要導入模塊: import mpld3 [as 別名]
# 或者: from mpld3 import fig_to_html [as 別名]
def coinc_timeseries_plot(coinc_file, start, end):
    fig = pylab.figure()
    f = h5py.File(coinc_file, 'r')

    stat1 = f['foreground/stat1']
    stat2 = f['foreground/stat2']
    time1 = f['foreground/time1']
    time2 = f['foreground/time2']
    ifo1 = f.attrs['detector_1']
    ifo2 = f.attrs['detector_2']

    pylab.scatter(time1, stat1, label=ifo1, color=ifo_color[ifo1])
    pylab.scatter(time2, stat2, label=ifo2, color=ifo_color[ifo2])

    fmt = '.12g'
    mpld3.plugins.connect(fig, mpld3.plugins.MousePosition(fmt=fmt))
    pylab.legend()
    pylab.xlabel('Time (s)')
    pylab.ylabel('NewSNR')
    pylab.grid()
    return mpld3.fig_to_html(fig) 
開發者ID:gwastro,項目名稱:pycbc,代碼行數:23,代碼來源:followup.py

示例4: trigger_timeseries_plot

# 需要導入模塊: import mpld3 [as 別名]
# 或者: from mpld3 import fig_to_html [as 別名]
def trigger_timeseries_plot(file_list, ifos, start, end):

    fig = pylab.figure()
    for ifo in ifos:
        trigs = columns_from_file_list(file_list,
                                       ['snr', 'end_time'],
                                       ifo, start, end)
        print(trigs)
        pylab.scatter(trigs['end_time'], trigs['snr'], label=ifo,
                      color=ifo_color[ifo])

        fmt = '.12g'
        mpld3.plugins.connect(fig, mpld3.plugins.MousePosition(fmt=fmt))
    pylab.legend()
    pylab.xlabel('Time (s)')
    pylab.ylabel('SNR')
    pylab.grid()
    return mpld3.fig_to_html(fig) 
開發者ID:gwastro,項目名稱:pycbc,代碼行數:20,代碼來源:followup.py

示例5: on_epoch_end

# 需要導入模塊: import mpld3 [as 別名]
# 或者: from mpld3 import fig_to_html [as 別名]
def on_epoch_end(self, epoch=None, logs={}):
        fig = self.generate_plot()
        html = mpld3.fig_to_html(fig)
        return requests.patch(self.app_url, json={
            'name': self.name, 'type': 'html', 'value': html,
            'pos': self.position, 'description': self.description}) 
開發者ID:AgnezIO,項目名稱:agnez,代碼行數:8,代碼來源:app_callbacks.py

示例6: loadSystem

# 需要導入模塊: import mpld3 [as 別名]
# 或者: from mpld3 import fig_to_html [as 別名]
def loadSystem():
	return m.fig_to_html(system.fig) 
開發者ID:jusjusjus,項目名稱:Motiftoolbox,代碼行數:4,代碼來源:webrun.py

示例7: loadTorus

# 需要導入模塊: import mpld3 [as 別名]
# 或者: from mpld3 import fig_to_html [as 別名]
def loadTorus():
	return m.fig_to_html(torus.fig) 
開發者ID:jusjusjus,項目名稱:Motiftoolbox,代碼行數:4,代碼來源:webrun.py

示例8: loadNetwork

# 需要導入模塊: import mpld3 [as 別名]
# 或者: from mpld3 import fig_to_html [as 別名]
def loadNetwork():
	return m.fig_to_html(network.fig) 
開發者ID:jusjusjus,項目名稱:Motiftoolbox,代碼行數:4,代碼來源:webrun.py

示例9: loadTraces

# 需要導入模塊: import mpld3 [as 別名]
# 或者: from mpld3 import fig_to_html [as 別名]
def loadTraces():
	return m.fig_to_html(traces.fig) 
開發者ID:jusjusjus,項目名稱:Motiftoolbox,代碼行數:4,代碼來源:webrun.py

示例10: loadInfo

# 需要導入模塊: import mpld3 [as 別名]
# 或者: from mpld3 import fig_to_html [as 別名]
def loadInfo():
	return m.fig_to_html(info.fig) 
開發者ID:jusjusjus,項目名稱:Motiftoolbox,代碼行數:4,代碼來源:webrun.py

示例11: get_graph_html_or_send_error

# 需要導入模塊: import mpld3 [as 別名]
# 或者: from mpld3 import fig_to_html [as 別名]
def get_graph_html_or_send_error(figure) -> Union[str, ResponseType]:
    try:
        figure.set_size_inches(11, 5.2)
        return mpld3.fig_to_html(figure,
                                 template_type="simple",
                                 figid="plot",
                                 no_extras=True)
    except Exception as e:
        logging.exception("Model error")
        raise ServerException(str(e), http.HTTPStatus.INTERNAL_SERVER_ERROR) 
開發者ID:felicityallen,項目名稱:SelfTarget,代碼行數:12,代碼來源:server.py

示例12: save_html_with_metadata

# 需要導入模塊: import mpld3 [as 別名]
# 或者: from mpld3 import fig_to_html [as 別名]
def save_html_with_metadata(fig, filename, fig_kwds, kwds):
    """ Save a html output to file with metadata """
    if isinstance(fig, str):
        text = fig
    else:
        from mpld3 import fig_to_html
        text = fig_to_html(fig, **fig_kwds)

    f = open(filename, 'w')
    for key, value in kwds.items():
        value = escape(value, escape_table)
        line = "<div class=pycbc-meta key=\"%s\" value=\"%s\"></div>" % (str(key), value)
        f.write(line)

    f.write(text) 
開發者ID:gwastro,項目名稱:pycbc,代碼行數:17,代碼來源:metadata.py

示例13: save_html

# 需要導入模塊: import mpld3 [as 別名]
# 或者: from mpld3 import fig_to_html [as 別名]
def save_html(self, output_html, html_script=None, html_body=None):
        """Save figure as HTML.

        Parameters
        ----------
        output_html : str
            Name of output file.
        html_script : str
            Additional java script to append to script section.
        html_body : str
            Additional HTML to append to end of the body section.
        """

        try:
            __import__('mpld3')
        except ImportError:
            print('[Error] The mpld3 module is required to save HTML figures.')
            sys.exit()

        import mpld3

        # modify figure properties for better web viewing
        self.fig.dpi = 96
        html_str = mpld3.fig_to_html(self.fig, template_type='simple')

        if html_script:
            html_script_start = html_str.find('<script type="text/javascript">') + len('<script type="text/javascript">')
            html_str = html_str[0:html_script_start] + '\n' + html_script + '\n' + html_str[html_script_start:]

        if html_body:
            html_str += '\n<body>\n' + html_body + '\n</body>\n'

        html_str = '<center>' + html_str + '</center>'

        fout = open(output_html, 'w')
        fout.write(html_str)
        fout.close()

        # restore figure properties
        self.fig.dpi = self.options.dpi 
開發者ID:jtamames,項目名稱:SqueezeMeta,代碼行數:42,代碼來源:abstract_plot.py


注:本文中的mpld3.fig_to_html方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。