我有一个华盛顿的图表,DC公寓价格,我想其中一个下拉选项是“年建成”.这是我到目前为止的代码:
dropdown = alt.binding_select (options=["Square Feet", "Year built", "Rooms"], name="Select a size variable:")
# Create a new selection that uses my dynamic query widget
selection = alt.selection(type="single", fields=['column'], bind=dropdown, init={'column':'Square Feet'})
alt.Chart(altdat, title='Washington, D.C. condos, by price').transform_fold(
["Square Feet", "Year built", "Rooms"],
as_=['column', 'value']
).transform_filter(
selection
).mark_circle().encode(
x = alt.X('Longitude', scale=alt.Scale(domain=[altdat['Longitude'].min(), altdat['Longitude'].max()])),
y = alt.Y("Latitude", scale=alt.Scale(domain=[altdat['Latitude'].min(), altdat['Latitude'].max()])),
color=alt.Color('Price (city appraisal)', scale=alt.Scale(scheme='redyellowgreen', reverse=True)),
size="value:Q",
tooltip=["WARD", "Square Feet", "Year built", "Rooms"]
).add_selection(selection
).properties(
width=600,
height=600
).interactive()
但是,当我选择年份作为下拉列表时,刻度从0到2000,使其无效。Altair image如何仅将年份变量的刻度从1800调整到2000?我仍然希望平方英尺从0到2000。谢谢!
1条答案
按热度按时间aiazj4mn1#
如果您不希望在默认情况下将零包括在刻度中,您可以设置
scale=alt.Scale(zero=False)
(不完全确定这是您所问的,我无法测试它,因为问题中没有提供数据)。