3

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 .

Miguel
  • 981
  • 5
  • 13

1 Answers1

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.

Mathematica graphics

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.

Mathematica graphics

Szabolcs
  • 234,956
  • 30
  • 623
  • 1,263