我正在尝试更改 plotly
中的背景颜色,但在使用布局功能后,我缺少了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()
。很难弄清楚你的 plotly 有什么问题,但以 plot.ly/python/horizontal-bar-charts/ 为例您可以使用 fig.update_layout()
plotly :
代码:
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()
关于python - 绘图中缺少显示的标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58228675/