如何在 Plotly (python) 中设置背景颜色、标题?
How to set background color, title in Plotly (python)?
下面是我的代码,谁能告诉我如何设置背景颜色、标题、x-axis y-axis 标签:
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 : 直接显示在网页中。
您可以通过创建布局设置背景颜色object
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。
要设置标题和轴标签,向布局添加属性object (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'
)
)
下面是我的代码,谁能告诉我如何设置背景颜色、标题、x-axis y-axis 标签:
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 : 直接显示在网页中。
您可以通过创建布局设置背景颜色object
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。
要设置标题和轴标签,向布局添加属性object (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'
)
)