Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fill, zindex, blending #3704

Open
liquidcarbon opened this issue Dec 1, 2024 · 0 comments
Open

Fill, zindex, blending #3704

liquidcarbon opened this issue Dec 1, 2024 · 0 comments

Comments

@liquidcarbon
Copy link

liquidcarbon commented Dec 1, 2024

What is your suggestion?

I was trying to place certain lines (mark_line or mark_rule) behind point markers using opacity and got some confusing results.

It would be nice to see a tutorial on how blending works.

Additionally, looks like Vega allows z-index for particular marks, but Altair only supports it for axes and legends? https://vega.github.io/vega/docs/marks/rule/

Have you considered any alternative solutions?

import altair as alt
import pandas as pd

lines_df = pd.DataFrame({"x": [0, 1], "y": [0, 0]})
points_df = pd.DataFrame({"x": [0, 1], "y": [0, 0]})


points = alt.Chart(points_df).mark_circle(
    size=900,
    # opacity=1
).encode(
    x="x", y="y",
    fill=alt.value("red"),
    # fillOpacity=alt.value(1)  # blends
)
lines = alt.Chart(lines_df).mark_line().encode(x="x", y="y")
# alternatively using `mark_rule` on "wide" `x/x2/y/y2` dataset
lines+points

Using "opacity" in mark_circle works as expected (line is covered by circle), but using fillOpacity it's partially see through; using lines + points + points layers on some more red, but the circles remain partially transparent.

Using property "blend" was even more confusing; it seems that three-way blending of lines, circles, and background is happening, making it difficult to tell how different modes work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant