# Opacity gradient in custom legend

I need to produce the legend of a plot which encodes a color gradient together with a color gradient. In particular, I would like the image bellow to have the blueish edge faded and the redish solid:

I thought Graphics would be a good way to implement it, but I couldn't figure out how to implement such varying opacity. This would be the legend of the following plot

as you can see, the points at the plot display such gradient, but the way I implemented it was assigning an opacity to each point at the listplot, and this does not seem to work either for Graphics or for the above shown Bar Legend.

"to have the blueish edge faded and the redish solid::

You can use a list of colors with desired opacities as option value for "ColorScheme". For example,

colorscheme = Append[ColorData["DarkRainbow"]@#, .01 + #] & /@ Subdivide[10];


BarLegend["Rainbow", OpacityFunction -> (# &)]

This is used in built-in functions such as DensityPlot3D.