我正在尝试使用以下代码在 Altair 中绘制图表。
tot_matches_played = alt.Chart(mpt).mark_bar().encode(
alt.X('Team',axis=alt.Axis(title='Teams Played in IPL'), sort=alt.EncodingSortField(field='Number_of_matches_played:Q', op='count', order='ascending')),
alt.Y('Number_of_matches_played:Q' ),
tooltip=['sum(Number_of_matches_played)']
)
但由于工具提示名称很奇怪,我想在图表上使用“as”重命名它,如下所示。
tot_matches_played = alt.Chart(mpt).mark_bar().encode(
alt.X('Team',axis=alt.Axis(title='Teams Played in IPL'), sort=alt.EncodingSortField(field='Number_of_matches_played:Q', op='count', order='ascending')),
alt.Y('Number_of_matches_played:Q' ),
tooltip=['sum(Number_of_matches_played)' as total_matches]
)
如何重命名工具提示,以便查看图表的用户以更易读的方式显示它。