简体   繁体   English

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

[英]How to show part of the repeated chart in altair

i have used repeat in altair and the Result looks like this.我在 altair 中使用了重复,结果看起来像这样。

在此处输入图像描述

i was wondering how can i only show the Lower part that i have marked with a Red triangle.我想知道如何只显示我用红色三角形标记的下部。

the code that i have used:我使用的代码:

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()

It seems that altair can't do it by itself.看来altair自己做不到。 The reason is confirmed https://github.com/altair-viz/altair/issues/2321 : altair's maintainer @joelostblom has developed a wrapper package.原因已确认https://github.com/altair-viz/altair/issues/2321 :altair 的维护者@joelostblom 开发了一个包装器 package。 See https://joelostblom.github.io/altair_ally/examples.html .请参阅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')

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM