Black Lives Matter. Please consider donating to Black Girls Code today.

Custom Hovertext obstructs plot view. Opacity/bottom of plot?

Is there a way to add custom hovertext that has a background with opacity? I know there is opacity for many other plotly objects(see below), but the tooltip is such that it can obstruct the view of what is being plotted.

There is a way to do this in python, but in R, it’s tough. There is no value for opacity on a tooltip.
Python code below:
import plotly.plotly as py
import plotly.graph_objs as go
import random
import numpy as np
import pandas as pd

l= []
y= []
data= pd.read_csv(“https://raw.githubusercontent.com/plotly/datasets/master/2014_usa_states.csv”)

Setting colors for plot.

N= 53
c= [‘hsl(’+str(h)+’,50%’+’,50%)’ for h in np.linspace(0, 360, N)]

for i in range(int(N)):
y.append((2000+i))
trace0= go.Scatter(
x= data[‘rank’],
y= data[‘pop’]+(i*1000000),
mode= ‘markers’,
marker= dict(size= 14,
line= dict(width=1),
color= c[i],
opacity= 0.3
),name= y[i],
text= data[‘state’]) # The hover text goes here…
l.append(trace0);

layout= go.Layout(
title= ‘Stats of USA States’,
hovermode= ‘closest’,
xaxis= dict(
title= ‘Pop’,
ticklen= 5,
zeroline= False,
gridwidth= 2,
),
yaxis=dict(
title= ‘Rank’,
ticklen= 5,
gridwidth= 2,
),
showlegend= False
)
fig= go.Figure(data=l, layout=layout)
py.iplot(fig)

I managed to get a working example of how opacity should work, but for some reason does not:
mat <- scale(mtcars, center = TRUE, scale = TRUE)
data<-mat
p<-plot_ly(x=colnames(data), y=rownames(data), z = data, type = “heatmap”, colors = colorRamp(c(“blue”, “red”)),hoverlabel=list(bgcolor=‘rgba(7, 164, 181, 0.2)’)) %>% layout(
title = “Set hover text formatting
https://github.com/d3/d3-time-format/blob/master/README.md#locale_format”,
titlefont = list(
size = 10
),
xaxis = list(
zeroline = F
),
yaxis = list(
hoverformat = ‘.2f’,alpha=0.2
)
)
p

The RGBA value doesn’t actually change alpha because there is a white background stuck on the hover label.