本文整理匯總了Python中plotly.graph_objects.Layout方法的典型用法代碼示例。如果您正苦於以下問題:Python graph_objects.Layout方法的具體用法?Python graph_objects.Layout怎麽用?Python graph_objects.Layout使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類plotly.graph_objects
的用法示例。
在下文中一共展示了graph_objects.Layout方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: score_table
# 需要導入模塊: from plotly import graph_objects [as 別名]
# 或者: from plotly.graph_objects import Layout [as 別名]
def score_table(quality_estimation, field_accuracy) -> go.FigureWidget:
cells = [
["<b>Field Accuracy Score</b>", "<b>Overall Quality Score</b>"],
["<b>" + str(field_accuracy) + "<b>", "<b>" + str(quality_estimation) + "</b>"],
]
font = dict(color="black", size=20)
trace = go.Table(
header=dict(
values=[cells[0][0], cells[1][0]], fill=dict(color="gray"), font=font
),
cells=dict(
values=[cells[0][1:], cells[1][1:]],
fill=dict(color=[[get_color(quality_estimation)]]),
font=font,
),
)
layout = go.Layout(autosize=True, margin=dict(l=0, t=25, b=25, r=0), height=150)
return go.FigureWidget(data=[trace], layout=layout)
示例2: make_chart
# 需要導入模塊: from plotly import graph_objects [as 別名]
# 或者: from plotly.graph_objects import Layout [as 別名]
def make_chart(title):
import json
import plotly.graph_objects as go
import plotly
layout = go.Layout(title=title)
data = go.Scatter(
x=[1, 2, 3, 4],
y=[10, 11, 12, 13],
mode="markers",
marker=dict(size=[40, 60, 80, 100], color=[0, 1, 2, 3]),
)
fig = go.Figure(data=data)
fig = json.dumps(fig, cls=plotly.utils.PlotlyJSONEncoder)
layout = json.dumps(layout, cls=plotly.utils.PlotlyJSONEncoder)
return fig, layout
示例3: performance_plot
# 需要導入模塊: from plotly import graph_objects [as 別名]
# 或者: from plotly.graph_objects import Layout [as 別名]
def performance_plot(perf, title):
formats = ['nbformat'] + JUPYTEXT_FORMATS
mean = perf.groupby('implementation').mean().loc[formats]
std = perf.groupby('implementation').std().loc[formats]
data = [go.Bar(x=mean.index,
y=mean[col],
error_y=dict(
type='data',
array=std[col],
color=color,
thickness=0.5
) if col != 'size' else dict(),
name=col,
yaxis={'read': 'y1', 'write': 'y2', 'size': 'y3'}[col])
for col, color in zip(mean.columns, DEFAULT_PLOTLY_COLORS)]
layout = go.Layout(title=title,
xaxis=dict(title='Implementation', anchor='y3'),
yaxis=dict(domain=[0.7, 1], title='Read (secs)'),
yaxis2=dict(domain=[0.35, .65], title='Write (secs)'),
yaxis3=dict(domain=[0, .3], title='Size')
)
return go.Figure(data=data, layout=layout)
示例4: get_layout
# 需要導入模塊: from plotly import graph_objects [as 別名]
# 或者: from plotly.graph_objects import Layout [as 別名]
def get_layout(name: str, rows_count: int) -> go.Layout:
return go.Layout(
title=name,
bargap=0.1,
template="seaborn",
height=min(max(rows_count * 20, 200), 900),
hovermode="y",
margin=dict(l=200, t=35),
)
示例5: coverage_by_categories
# 需要導入模塊: from plotly import graph_objects [as 別名]
# 或者: from plotly.graph_objects import Layout [as 別名]
def coverage_by_categories(category_field, df, product_url_fields) -> go.FigureWidget:
if category_field not in df.columns:
return None
if df[category_field].notnull().sum() == 0:
return None
cat_grouping = (
df.groupby(category_field)[category_field]
.count()
.sort_values(ascending=False)
.head(20)
)
category_values = cat_grouping.values
category_names = cat_grouping.index
if product_url_fields is not None and product_url_fields[0] in df.columns:
product_url_field = product_url_fields[0]
category_urls = [
df[df[category_field] == cat][product_url_field].head(1).values[0]
for cat in category_names
]
href_tag = '<a href="{}">{}</a>'
category_names = [
href_tag.format(link, cat)
for cat, link in zip(category_names, category_urls)
]
trace = go.Table(
columnorder=[1, 2],
columnwidth=[400, 80],
header=dict(
values=[f"CATEGORY", "SCRAPED ITEMS"],
fill=dict(color="gray"),
align=["left"] * 5,
font=dict(color="white", size=12),
height=30,
),
cells=dict(
values=[category_names, category_values],
fill=dict(color="lightgrey"),
font=dict(color="black", size=12),
height=30,
align="left",
),
)
layout = go.Layout(
title=f"Top 20 Categories for '{category_field}'",
autosize=True,
margin=dict(t=30, b=25, l=0, r=0),
height=(len(category_names) + 2) * 45,
)
return go.FigureWidget(data=[trace], layout=layout)