本文整理汇总了Python中plotly.io.write_image方法的典型用法代码示例。如果您正苦于以下问题:Python io.write_image方法的具体用法?Python io.write_image怎么用?Python io.write_image使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plotly.io
的用法示例。
在下文中一共展示了io.write_image方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: bar_chart
# 需要导入模块: from plotly import io [as 别名]
# 或者: from plotly.io import write_image [as 别名]
def bar_chart(self, node):
fig = dict(
data=[
dict(
values=list(node.members.values()),
labels=list(node.members),
showlegend=(node.node_id == 0),
**FIG_BASE_DATA
)
],
**FIG_BASE
)
if not node.is_terminal:
fig["data"].append(self._table(node))
filename = os.path.join(self.tempdir, "node-{}.png".format(node.node_id))
pio.write_image(fig, file=filename, format="png")
return filename
示例2: save_static
# 需要导入模块: from plotly import io [as 别名]
# 或者: from plotly.io import write_image [as 别名]
def save_static(self):
try:
pio.write_image(self.fig, self.path.replace('html', 'png'))
except ValueError as e:
logging.warning("Nanoplotter: orca not found, not creating static image of html. "
"See https://github.com/plotly/orca")
logging.warning(e, exc_info=True)
示例3: save_image
# 需要导入模块: from plotly import io [as 别名]
# 或者: from plotly.io import write_image [as 别名]
def save_image(figure, filepath):
if os.environ['PY_ENV'] == 'test':
return
filepath = util.smart_path(filepath)
try:
pio.write_image(figure, filepath)
except Exception as e:
orca_warn_once(e)
# analysis plot methods
示例4: save_image
# 需要导入模块: from plotly import io [as 别名]
# 或者: from plotly.io import write_image [as 别名]
def save_image(figure, filepath):
if os.environ['PY_ENV'] == 'test':
return
filepath = util.smart_path(filepath)
try:
pio.write_image(figure, filepath, scale=2)
except Exception as e:
orca_warn_once(e)
# analysis plot methods
示例5: plot
# 需要导入模块: from plotly import io [as 别名]
# 或者: from plotly.io import write_image [as 别名]
def plot(self, front, label=None, normalize: bool = False, filename: str = None, format: str = 'HTML'):
""" Plot a front of solutions (2D, 3D or parallel coordinates).
:param front: List of solutions.
:param label: Front name.
:param normalize: Normalize the input front between 0 and 1 (for problems with more than 3 objectives).
:param filename: Output filename.
"""
if not isinstance(label, list):
label = [label]
self.layout = go.Layout(
margin=dict(l=80, r=80, b=80, t=150),
height=800,
title='{}<br>{}'.format(self.plot_title, label[0]),
scene=dict(
xaxis=dict(title=self.axis_labels[0:1][0] if self.axis_labels[0:1] else None),
yaxis=dict(title=self.axis_labels[1:2][0] if self.axis_labels[1:2] else None),
zaxis=dict(title=self.axis_labels[2:3][0] if self.axis_labels[2:3] else None)
),
hovermode='closest'
)
# If any reference front, plot
if self.reference_front:
points, _ = self.get_points(self.reference_front)
trace = self.__generate_trace(points=points, legend='Reference front', normalize=normalize,
color='black', size=2)
self.data.append(trace)
# If any reference point, plot
if self.reference_point:
points = pd.DataFrame(self.reference_point)
trace = self.__generate_trace(points=points, legend='Reference point', color='red', size=8)
self.data.append(trace)
# Get points and metadata
points, _ = self.get_points(front)
metadata = list(solution.__str__() for solution in front)
trace = self.__generate_trace(points=points, metadata=metadata, legend='Front approximation',
normalize=normalize)
self.data.append(trace)
self.figure = go.Figure(data=self.data, layout=self.layout)
# Plot the figure
if filename:
if format == 'HTML':
self.export_to_html(filename)
else:
pio.write_image(self.figure, filename + '.' + format)