For reasons too lengthy to explain, I would like to display a list of dates or years (as numbers or strings) as FrameTicks
on a ListLinePlot
.
An example of what I have so far follows:
xle = FinancialData["XLE", All];
DateListPlot[xle, ImageSize -> 350]
ListLinePlot[xle[[All, 2]], ImageSize -> 350]
firstDateByYear = First /@ SplitBy[xle[[All, 1]], #[[1]] &]
positions = Flatten[Position[xle[[All, 1]], #] & /@ firstDateByYear]
years= firstDateByYear[[All,1]]
{{1998, 12, 22}, {1999, 1, 4}, {2000, 1, 3}, {2001, 1, 2}, {2002, 1, 2},{2003, 1, 2}, {2004, 1, 2}, {2005, 1, 3}, {2006, 1, 3}, {2007, 1, 3}, {2008, 1, 2}, {2009, 1, 2}, {2010, 1, 4}, {2011, 1, 3}, {2012, 1, 3}}
{1, 8, 260, 512, 760, 1012, 1264, 1516, 1768, 2019, 2270, 2523, 2775, 3027, 3279}
{1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012}
I thought that identifying a position at which I wanted to place a label would help.
The following earlier question Formatting Ticks and FrameTicks labels with a function relates to what I want to do, but I haven't understood it sufficiently to adapt it to my needs.
Doing something like placing a string for the year at every other position in the list "positions" would give me a clear idea of how to do more complicated things on my own.