plotly hoverlabel 颜色透明度 [英] plotly hoverlabel color transparency
问题描述
是否可以格式化 hoverlabel
使背景颜色透明&可以通过标签看到剧情吗?
Is it possible to format hoverlabel
so that the background color is transparent & it's possible to see the plot through the labels?
我可以将其设置为纯色,例如hoverlabel = list(bgcolor = '#fff')
但看起来如果我尝试添加透明度,颜色字符串的那部分会被忽略.与 bgcolor = 'rgba(255,255,255,0.05)'
相同,也不起作用.看起来标记有 opacity
设置,但没有悬停标签.
I can set it to a solid color by e.g. hoverlabel = list(bgcolor = '#fff')
but looks like if I try to add transparency, that part of the color string gets ignored. Same with bgcolor = 'rgba(255,255,255,0.05)'
, doesn't work either. Looks like for markers there is opacity
setting, but not for hoverlabels.
谢谢!!
推荐答案
我发现(在 plotly python 中),如果你在 layout
,那么如果你将 bgcolor
设置为一些包含透明度的 rgba
值,它确实有效!我不知道 R 代码,但应该很容易弄清楚.这就是它的样子(我觉得很恶心!)-
I have found (in plotly python), that if you pass hovermode = "x unified"
in layout
, then if you set bgcolor
to some rgba
value that includes transparency, it does work! I am not aware of the R code for that but it should be easy to figure out. Here's what it looks like (pretty sick imo!) -
这是(python)代码-
Here's the (python) code-
fig.update_layout(hovermode='x unified', legend=dict(title= None), hoverlabel=dict(bgcolor='rgba(255,255,255,0.75)',
font=dict(color='black')))
这篇关于plotly hoverlabel 颜色透明度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!