I am looking for a better way to specify the spacing between ChartLabels
when using BarChart. My current implementation uses Riffle
and Splice
(new in version 12.1) to splice empty strings into a list of dates. The labels could be anything, but I'm working with dates. For this example, I've created an arbitrary list of numbers for the BarChart
data.
My method works, but I'm wondering if I'm missing some option/technique that could be better. Here's my working code:
dayInc = 5;
dateRng = DateRange[DateObject[{2020, 2, 1}], Today, Quantity[dayInc, "Days"]];
dateStr = Riffle[
Map[DateString[#, {"MonthShort", "/", "DayShort", "/", "YearShort"}] &][dateRng],
Splice[Table["", {dayInc - 1}]]
];
data = Range[Length[dateStr]];
BarChart[data,
ChartLabels -> Placed[dateStr, Below, Rotate[#1, 60 Degree] &]]