fig=px.histogram(df,x='x',facet_row='Date',color='c',
barmode='overlay',facet_col='number',height=500)
for a in fig.layout.annotations:
a.text = a.text.split("=")[1]
fig.show()
for i, a in enumerate(fig['layout']['annotations']):
if a['text'][:4]=='time':
a['x']=0.475
a['font']=dict(size = 10, color='rgba(255,0,200,0.8)')
print(a)
fig.show()
绘图1:
代码1:
这里,与要移动的元素相对应的元素是
'time=Lunch'
和'time=Dinner'
。因此,在这种情况下,可以沿x轴将元素放置在任意位置,如下所示:代码:2
绘图:2
我知道这是一个有点黑客的方法,但我希望你会发现它有用
相关问题 更多 >
编程相关推荐