How can I make DateListPlot show the iso week number? I would like to make a Date plot so that for each dot it will show the iso week date in the x-axis .
Asked
Active
Viewed 305 times
3
-
Related http://blog.wolfram.com/2015/07/09/new-in-the-wolfram-language-iso-dates-and-more/ – Dr. belisarius Oct 20 '15 at 22:28
-
Also related http://mathematica.stackexchange.com/q/15629/193 – Dr. belisarius Oct 20 '15 at 22:29
1 Answers
2
I don't see why this shouldn't work:
DateListPlot[FinancialData["IBM", "Jan. 1, 2015"], DateTicksFormat -> {"Week"}]
But it doesn't. There is only one tick mark.

It appears that DateString was updated at some point (I believe in 10.2, the documentation doesn't mention) to support many different formats, including ISO weeks. DateTicksFormat was not updated, at least the new formats are not mentioned in its documentation page.
It appears that DateTicksFormat might influence not only the content of tick labels (i.e. the labels themselves), but also the frequency of ticks. Something goes wrong when using a new format not mentioned in the DateTicksFormat documentation.
As a workaround I specified the ticks manually:
DateListPlot[FinancialData["IBM", "Jan. 1, 2015"],
DateTicksFormat -> {"Week"},
FrameTicks -> {{Automatic,
Automatic}, {DateRange[DateObject[{2015, 1, 1}], Today,
Quantity[2, "Weeks"]], Automatic}}]
To enter "2 weeks" and "January 1st 2015", I used Control-Enter with natural language input.

Szabolcs
- 234,956
- 30
- 623
- 1,263
-
I'm running 10.1 and I get "Week" for every x-axis tick using your code http://i.imgur.com/ODnQJ2A.png – Charlotte Hadley Oct 21 '15 at 15:16
-
@MartinJohnHadley That's because this is new in 10.2 I think, see the link posted by belisarius. The documentation doesn't say when the update happened. – Szabolcs Oct 21 '15 at 16:03
-
If it worked in 10.1, it went kaput in 10.2; I get the same thing as Szabolcs. – J. M.'s missing motivation Oct 21 '15 at 16:10
-
Great, thanks. I need to update sorely but keep putting it off – Charlotte Hadley Oct 21 '15 at 16:11
-
2@MartinJohnHadley Personally I hadn't noticed any big problems (regressions) with 10.3 yet ... This performance regression is the only one I know of. But then I only use a very limited subset of Mathematica. – Szabolcs Oct 21 '15 at 16:24
-
DateListPlot[FinancialData["IBM", "Jan. 1, 2015"], DateTicksFormat -> {"Week", "-", "Month"}]does work,DateListPlot[FinancialData["IBM", "Jan. 1, 2015"], DateTicksFormat -> {"Week", "-", "Year"}]does not. – Karsten7 Oct 21 '15 at 19:10 -