本文整理汇总了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)
示例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>'''
示例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)
示例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)
示例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})
示例6: loadSystem
# 需要导入模块: import mpld3 [as 别名]
# 或者: from mpld3 import fig_to_html [as 别名]
def loadSystem():
return m.fig_to_html(system.fig)
示例7: loadTorus
# 需要导入模块: import mpld3 [as 别名]
# 或者: from mpld3 import fig_to_html [as 别名]
def loadTorus():
return m.fig_to_html(torus.fig)
示例8: loadNetwork
# 需要导入模块: import mpld3 [as 别名]
# 或者: from mpld3 import fig_to_html [as 别名]
def loadNetwork():
return m.fig_to_html(network.fig)
示例9: loadTraces
# 需要导入模块: import mpld3 [as 别名]
# 或者: from mpld3 import fig_to_html [as 别名]
def loadTraces():
return m.fig_to_html(traces.fig)
示例10: loadInfo
# 需要导入模块: import mpld3 [as 别名]
# 或者: from mpld3 import fig_to_html [as 别名]
def loadInfo():
return m.fig_to_html(info.fig)
示例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)
示例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)
示例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