[英]Altair python - how to align x axis (=0) for charts within a for
I want to align al charts generated in a loop, but x axis do not start at the same vertical line, because of the 'y' labels.我想对齐循环中生成的所有图表,但由于“y”标签,x 轴不会从同一垂直线开始。 See below:见下文:
for campo in [col for col in nomina.columns if col!= 'Fecha ingreso']:
a = alt.Chart(nomina[[campo]]).mark_bar().encode(
x='count(' + campo + '):Q',
y=alt.Y('' + campo + ':N', sort='-x')
)
display(a.resolve_scale(x='shared'))
and I would like to see like this:我想看到这样的:
already figured it out.已经想通了。 I just had to add charts in a list, then use alt.vconcat(mylistcharts)!我只需要在列表中添加图表,然后使用 alt.vconcat(mylistcharts)!
charts = []
for campo in [col for col in nomina.columns if col!= 'Fecha ingreso']:
a = alt.Chart(nomina[[campo]]).mark_bar().encode(
x='count(' + campo + '):Q',
y=alt.Y('' + campo + ':N', sort='-x')
)
charts.append(a.resolve_scale(x='shared'))
alt.vconcat(*charts)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.