pray4shell
pray4shell

Reputation: 211

Can top layer chart marks totally cover lower layer chart marks in Altair?

I want a barbell style chart using Altair. Is there a way to totally hide the "bar" behind the "bells?" Even when the bell layer is on top, the bar is visible under the bells.

df = pd.DataFrame({'Category': ['Foo', 'Foo','Bar','Bar'],'Value':[10, 50, 20, 70], 'Start': [10, 10, 20, 20],'Stop': [50, 50, 70, 70], 'Level':['One','Two','One','Two']})

dot = alt.Chart(df).mark_circle(size=200,color='red').encode(
x=alt.X('Value:Q',axis=alt.Axis(grid=True)),    
y=alt.Y('Category:N',axis=alt.Axis(grid=False)))

line = alt.Chart(df).mark_rule(color='gray',size=3).encode(
alt.X('Start:Q'),alt.X2('Stop:Q'), 
y=alt.Y('Category:N'))

line+dot

barbell

Upvotes: 1

Views: 93

Answers (1)

eitanlees
eitanlees

Reputation: 1344

You can try setting the opacity to 1

dot = alt.Chart(df).mark_circle(size=200,color='red', opacity=1).encode(

enter image description here

Upvotes: 2

Related Questions