如何在 altair 中显示部分重复图表

How to show part of the repeated chart in altair

我在 altair 中使用了 repeat,结果如下所示。

我想知道如何只显示我用红色三角形标记的下部。

我用过的代码:

from sklearn import datasets
import altair as alt

data_wine = datasets.load_wine (as_frame = True).frame
features = data_wine.columns.values[data_wine.columns.values != 'target']
    
alt.Chart(data_wine).mark_circle().encode(
    alt.X(alt.repeat("column"), type = 'quantitative', scale = alt.Scale (nice = True)),
    alt.Y(alt.repeat("row"), type = 'quantitative', scale = alt.Scale (nice = True)),
    color = 'target:N'
).properties(
    width=150,
    height=150
).repeat(
    row = features,
    column = features
)#.interactive()

看来altair自己做不到。原因确认https://github.com/altair-viz/altair/issues/2321: There is an experimental wrapper package with a more terse syntax for common exploratory plots that you could try out. See https://joelostblom.github.io/altair_ally/examples.html.

from sklearn import datasets
import altair as alt
import altair_ally as aly

data_wine = datasets.load_wine (as_frame = True).frame
features = data_wine.columns.values[data_wine.columns.values != 'target']
data_wine['target'] = data_wine['target'].astype(str)

aly.pair(data_wine,'target')