下面是我的代码,谁能告诉我如何设置背景颜色、标题、x 轴 y 轴标签:
scatterplot = plot([Scatter(x=x.index,
y=x['rating'],
mode='markers',
marker=dict(size=10,
color=x['value'],
colorscale='Viridis',
showscale=True),
text=(x['value'] + ' ' + x['Episode'] + '<br>' + x['label']))],
output_type='div'
)
P.S:这是直接在网页上显示的。
请您参考如下方法:
您可以通过创建 Layout 对象设置背景颜色
layout = Layout(
plot_bgcolor='rgba(0,0,0,0)'
)
data = Data([
Scatter( ... )
])
fig = Figure(data=data, layout=layout)
plot(fig, output_type='div')
如果您想要透明背景,请参阅 this post .
要设置标题和轴标签,请将属性添加到 Layout 对象 (see the docs):
title='Plot Title',
xaxis=dict(
title='x Axis',
titlefont=dict(
family='Courier New, monospace',
size=18,
color='#7f7f7f'
)
),
yaxis=dict(
title='y Axis',
titlefont=dict(
family='Courier New, monospace',
size=18,
color='#7f7f7f'
)
)
