python - 缺少标题显示在情节中
问题描述
我正在尝试更改背景颜色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)
解决方案
我尝试为 iplot 本身添加布局并且它有效。我们也可以随之调整边距。
示例代码:
data['Nationality'].value_counts()[0:10][::-1].iplot(kind="barh",bargap=.5,
colors="mediumorchid", layout=Layout(paper_bgcolor='rgba(0,0,0,0)',
plot_bgcolor='rgba(0,0,0,0)',
width=800, height=500,
title='Nationality of terrorist attacks',
margin=dict(l=200, r=50, t=80, b=50)))
推荐阅读
- kubernetes - Kustomize 将一个补丁应用于多种资源类型(添加 ownerReferences)
- c# - 将 ASP.Net 添加到现有项目
- python - 图像分割后的数据增强
- opencv - 基于(放大)OpenCV 风格相机参数的径向失真误差
- huawei-mobile-services - 在 HMS 插件文档中,您讨论了 HMS 管理器预制件......但是在您的 HMS 插件内容中没有名为“HMS 管理器”预制件的预制件
- kotlin - 在 Kotlin 中使用成员函数打印对象属性
- c - 打印共享内存的 C 指针
- c++ - 数组大小变量的值发生了变化,而我没有在我的 c++ 合并排序代码中显式地更改它
- sql - 比较本地数据库和远程数据库的表
- excel - 使用密码从下拉列表中取消隐藏 Excel 工作表