2016-07-19 442 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