Код: Выделить всё
import altair as alt
from vega_datasets import data
import polars as pl
# add a column indicating the year associated with each date
source = pl.from_pandas(data.stocks()).with_columns(year=pl.col.date.dt.year())
# an MSFT specific plot
msft_plot = (
alt.Chart(source.filter(pl.col.symbol.eq("MSFT")))
.mark_line()
.encode(x="date:T", y="price:Q", color="year:O")
)
# the original plot: https://altair-viz.github.io/gallery/line_chart_with_points.html
all_plot = (
alt.Chart(source)
.mark_line()
.encode(x="date:T", y="price:Q", color="symbol:N")
)
msft_plot & all_plot
[img]https://i.sstatic.net /xFqgDsbi.png[/img]
С другой стороны, если я рисую только all_plot:

Как остановить объединение легенд при объединении msft_plot и all_plot?< /п>
Подробнее здесь: https://stackoverflow.com/questions/791 ... -two-plots
Мобильная версия