Search code examples
altairvega-lite

Set opacity for marks but not in legend


I can modify the classic Simple Scatter Plot with Tooltips, to add opacity to marks, but I'd like to legend colors to stay 100% opaque. In the chart I'm trying to make, I have a df with tens of thousands of rows.

import altair as alt
from vega_datasets import data

source = data.cars()

alt.Chart(source).mark_circle(size=60, opacity=0.1).encode(
    x='Horsepower',
    y='Miles_per_Gallon',
    color='Origin'
)

chart result

I've tried alt.Legend's symbolOpacity and gradientOpacity to no avail

color=alt.Color(
    'Origin:N',
    legend=alt.Legend(
        # symbolOpacity=1,
        gradientOpacity=1,
)
)

Solution

  • As of now, this seems to be a bug with vega-lite. Per @jvp's suggestion, I've filed a bug report here

    UPDATE -- IT'S FIXED