[英]Missing title displayed in plotly
我正在嘗試更改plotly
中的背景顏色,但是在使用布局 function 之后,我缺少 plotly 的標題。
layout = Layout(
paper_bgcolor='rgba(0,0,0,0)',
plot_bgcolor='rgba(0,0,0,0)'
)
data['Country'].value_counts()[:10][::-1].iplot(kind="barh",bargap=.5, title="Top 10 countries faced terrorist attacks", colors="#182844", layout=layout)
最好使用go.Figure()
而不是iplot()
。 很難弄清楚 plot 的問題是什么,但是通過 plot.ly/python/horizontal-bar-charts/ 的示例,您可以使用fig.update_layout fig.update_layout()
輕松設置標題和背景顏色
Plot:
代碼:
import plotly.graph_objects as go
fig = go.Figure(go.Bar(
x=[20, 14, 23],
y=['giraffes', 'orangutans', 'monkeys'],
orientation='h'))
fig.update_layout(title='Title',
paper_bgcolor='rgba(0,0,0,0)',
plot_bgcolor='rgba(0,0,0,0)')
fig.show()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.