Hi,
Iāve been trying to display average salaries on a choropleth object, using color to communicate the ammount, as shown below:
However, I have a different ammount of entries for each country. That makes some strange artifacts in countries like Israel with only one entry with a very high pay. Instead of removing these, I would like instead to use transparency to convey āconfidenceā in the data: countries with low data will be less opaque. I already have a dictionary that correponds each country to its transparency. However, I canāt find a way to apply these values to the map. Hereās what Iāve tried:
opacities_dict = {k: np.log(len(df[df[select_filter] == k])) for i, k in enumerate(x) if k not in x[:i]}
opacities_dict = {k: (v + 1) / (max(opacities_dict.values()) + 1) for k, v in opacities_dict.items()}
#opacities_dict is something like: {"AU":0.7845698, "PT": 0.5698655, "US":1.0, ...}
fig = go.Figure(data=go.Choropleth(
locations = salaries['ISO_A2'],
text = salaries['ISO_A2'],
z = salaries['salary'],
colorbar_title="Salary in US$",
marker=dict(
# opacity=list(opacities_dict.values()), #this doesn't work, is overriden and opacity is set to 1
opacity=0.4, #this sets the whole map to the same opacity
# opacity = [0.4] #this is accepted but sets the whole map to the same opacity
),
))
I canāt find any documentation on passing an array of opacities to the opacity attribute. The only thing I find in the docs is that a 1-d array should be accepted, although I canāt see what the point would be if I could only pass a 1-value 1-d array:
Does anyone know how to achieve this, or something similar?