Repository navigation
Replies: 1 comment
|
Not as a setting yet. Vega-Lite's Changing only the label format looks like a fix but isn't. So yes, do it in pandas. Floor each date to the Monday of its week and let the axis print the ISO week: df["week"] = df["date"].dt.to_period("W-SUN").dt.start_time # Monday of the ISO week
chart = alt.Chart(df).mark_bar().encode(
x=alt.X("yearmonthdate(week):O", axis=alt.Axis(format="%G W%V")),
y="sum(value):Q",
)
I checked the bins and labels with Altair 6.3 rendered through vl-convert, on daily dates from Dec 28, 2024 to Jan 21, 2025, with the machine set to UTC, Los Angeles and Tokyo time. |
Uh oh!
There was an error while loading. Please reload this page.
Hi, I often use the date modifiers (week, date, yearmonth, yearweek, utcyearweek etc) I noticed that the week starts at 0 instead of 1. I also notice from https://vega.github.io/vega-lite/docs/timeunit.html that week returns sunday based weeks rather than ISO week number. Is it possible to change this? It'd be very useful
If it's not possible to change it what alternatives do you suggest? Calculating week number with a dataframe operation before plotting?
All reactions