为什么图例中没有列出两个颜色相似的圆圈?

Why there are two circles with similar colors that are not listed on legend?

为什么会这样?

我正在研究a gallery example Traffic 库,我在代码生成的图形上遇到了一个奇怪的事情。如果您仔细观察 10 月 19 日和 10 月 20 日在 06:00 和 08:00 处的圆圈,您会看到:

而且这两个圆圈里面还有一个深绿色的圆圈,很奇怪。

我的理论是浅绿色圆圈位于深绿色圆圈之上,但图例中并未列出这种深绿色。 在这里,我留下了生成该图的代码。

from traffic.data.datasets import landing_zurich_2019
import altair as alt

stats = (
    landing_zurich_2019.all("aligned_on_LSZH")
    .eval(desc="", max_workers=8)
    .rename(columns=dict(flight_id="old_flight_id"))
    .summary(["old_flight_id_max", "stop", "ILS_max"])
    .query("stop.dt.month == 10")
    .rename(columns=dict(ILS_max="ILS", old_flight_id_max="flight_id"))
    .sort_values("stop")
)

data = (
    stats.assign(hour=lambda df: df.stop.dt.round("1H"))
    .groupby(["ILS", "hour"])
    .agg(dict(stop="count"))
    .rename(columns=dict(stop="count"))
    .reset_index()
)

selection = alt.selection_multi(fields=["ILS"], bind="legend")

alt.Chart(data).encode(
    alt.X("utchours(hour):O", title="hour of day (UTC)",),
    alt.Y("utcmonthdate(hour):O", title=""),
    color="ILS",
    size="count",
    opacity=alt.condition(selection, alt.value(0.9), alt.value(0.2)),
).mark_circle().add_selection(selection)

是的,你说得对,这是因为你在绘制两个圆圈。可以在 10 月 26 日更清楚地看到,11:00 在您用红色和蓝色圆圈链接的示例中。如果您想更清楚地了解正在发生的事情,您可以使用 mark_point 来绘制空心圆。