首页 > 解决方案 > Altair - 条形图中缺少操作按钮

问题描述

Altair 新手(很棒的包!)

在 2 个类似的图表中,一个有操作按钮,而另一个没有。对此有何见解?我想在两者中都有操作按钮(保存到 SVG)。

以下代码:

chart = alt.Chart(df1).mark_bar(size = 25).encode(
    x = alt.X('drg3:N',sort=None, 
              axis = alt.Axis(title = "DRG")),
    y = alt.Y('discharges:Q', 
              axis = alt.Axis(title = "Discharges", format = "s"),
              scale = alt.Scale()),
).properties(
    title = "Top DRGs, based on Discharges in 2017",
)
chart

生成带有操作按钮的图表

在此处输入图像描述

但是,下面的代码


chart = alt.Chart(df1).mark_bar(size = 25).encode(
    x = alt.X('drg3:N',sort=None, 
              axis = alt.Axis(title = "DRG")),
    y = alt.Y('disc_times_pay:Q', 
              axis = alt.Axis(title = "Payments (in '000,000,000s')", format = "s"),
              scale = alt.Scale()),
).properties(
    title = "Top DRGs, based on Payments in 2017",
)
chart

生成类似的图表,但缺少操作按钮

在此处输入图像描述

标签: pythonaltair

解决方案


推荐阅读