如何在条形图的条形中间居中刻度线?
title = 'Submissions from Aug 2018 to Feb 2020 by Month'
chart = alt.Chart(df_US).mark_bar(size = 25,
color = 'black').encode(
x=alt.X('yearmonth(Time_Received):T',
axis =alt.Axis(format = "%b%y",
tickCount = 20,
tickBand = 'center')),
y='count(Time_Received)'
).configure_axisX( tickBand = 'center'
).properties(
width = 900,
title = title
).configure_axis(
grid=False
)
答案 0 :(得分:3)
将 'yearmonth(Time_Received):T'
更改为 'yearmonth(Time_Received):O'
:这将使其成为序数(即有序分类)编码,并且标签将默认出现在每个类别的中心。