Altair yaxis 限制免费

Altair yaxis limits free

我正在尝试使用 altair python 可视化库并让 facet 函数正常工作。但是,在图中,所有方面都具有相同的 y-lim。我想知道是否可以实现类似于 ggplot2 facet(~column, scales = "free")。有没有办法在 altair 中实现 scales == "free" ?我查看了文档,发现没有其他我可以调整的变量。

我使用的代码如下:

alt.Chart(sum_tf).mark_line().encode(
    x='month:Q',
    y='value:Q',
).properties(
    width=600,
    height=100
).facet(
    facet='variable:O',
    columns=1
)

您可以使用 resolve_scale 设置来控制复合图表中的比例是共享还是独立。默认情况下,比例是共享的:

alt.Chart(sum_tf).mark_line().encode(
    x='month:Q',
    y='value:Q',
).properties(
    width=600,
    height=100
).facet(
    facet='variable:O',
    columns=1
).resolve_scale(
    y='independent'
)

此处文档中的更多信息和示例:https://altair-viz.github.io/user_guide/scale_resolve.html