如何将文本页脚添加到 Altair 图形中?

How to add a Text Footer to an Altair graph?

可以向 Altair 图表添加页脚吗?

我一直在寻找选项,但我只找到了 textsubtitle 标题 properties()。

这是我的情节代码(来自串联图)

mobility_colima.configure_axis(
    labelFontSize=7,
    titleFontSize=7
).properties(
    title={
        "text":["Movilidad en CDMX"],
        "subtitle": ["Jay Ballesteros (@jballesterosc_)"],
    }
)

这是我要添加页脚的输出:

Altair 图表没有页脚 属性,但您可以滥用标题 属性 添加页脚。它可能看起来像这样:

import altair as alt
import numpy as np
import pandas as pd

x = np.arange(100)
source = pd.DataFrame({
  'x': x,
  'f(x)': np.sin(x / 5)
})

alt.Chart(source).mark_line().encode(
    x='x',
    y='f(x)'
).properties(
    title=alt.TitleParams(
        ['This is a fake footer.', 'If you want multiple lines,', 'you can put them in a list.'],
        baseline='bottom',
        orient='bottom',
        anchor='end',
        fontWeight='normal',
        fontSize=10
    )
)