2016-07-19 437 views
1

下面是我的代码,可能有人告诉我,我怎么设置背景颜色,标题,X轴Y轴标签:如何在Plotly(python)中设置背景颜色和标题?

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:这是直接显示在网页上。

回答

1

可以设置背景颜色通过如果你想有一个透明背景创建布局对象

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

要设置标题和轴标签,将属性添加到布局对象(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' 
    ) 
) 
+0

感谢,这解决了我的问题,让我知道如何工作的。 – sid8491

+0

@ user3196845请标记为已接受的答案,然后 – rawbeans

+0

标记为已接受,谢谢。 – sid8491