本文整理匯總了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)