简体   繁体   中英

How do I label a date axis in Altair with ticks every week?

It looks like Vega allows you to specify both resolution (eg day) and interval for date/time axes: https://vega.github.io/vega-lite/docs/axis.html#labels

{"interval": "month", "step": 3}

But when I try to specify alt.Axis(formatType="time", tickCount=alt.TickCount('day', step=7) , for example, I get an invalid schema error.

Is there a way to specify that I want date ticks every 7 days (ie weekly dates, not week number)?

Turns out there's a way to do this (sort of), which is to set the nice parameter in the alt.Scale , not in the axis as with Vega. So:

alt.Scale(nice={'interval': 'day', 'step': 7})

The problem is it seems to then round to nice values; so it won't start on the first day of data, but say the first of that day's month.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM