可以通过设置 altair 图表的config参数中的view属性,手动调整容器的宽度。
import altair as alt
# 数据
data = ...
# 图表
chart = alt.Chart(data).mark_bar().encode(
x='category:N',
y='cost:Q'
)
# 设置view的属性
chart.configure_view(
width=600, # 设置宽度
height=400
)
其中,设置的宽度和高度可以根据实际需要进行调整。