5
$\begingroup$

enter image description here

The code below generates the plot above,

DateListPlot[{Drop[series[7], 1], Drop[series[16], 1]},Joined -> True, 
              PlotMarkers -> {Automatic, Small}, Frame -> True,
              DateTicksFormat -> {"MonthNameShort", " ", "YearShort"} ] /.
              x : (FrameTicks -> _) :> (x /. s_String :> Rotate[s, 90 Degree])

I would like to show, on the x-axis, each and every one of the dates for which I have data. If that gets too cluttered then I would like to show a sampling of it that covers some of the staggered months. I will paste this into a pdf so tooltips won't be of use. Maybe for within year data, I can mention just the month, if it will improve readability. With non-date data, I know that I can enter ticknames and tick positions but I don't know how to do it with date data and also, I was wondering if this could be automated where I could tell it to show only the month for certain dates and month-year for others.

$\endgroup$
1

1 Answer 1

10
$\begingroup$

Use the data as ticks.

data = WolframAlpha["brad pitt", 
         {{"PopularityPod:WikipediaStatsData", 1}, "TimeSeriesData"}];

rarify = data[[1 ;; -1 ;; 10]];

DateListPlot[rarify, FrameTicks -> {rarify[[All, 1]], Automatic}, 
  Filling -> Bottom, PlotMarkers -> {Automatic, Small}, Frame -> True,
   DateTicksFormat -> {"MonthNameShort", " ", "YearShort"}] /. 
 x : (FrameTicks -> _) :> (x /. s_String :> Rotate[s, 90 Degree])

enter image description here

$\endgroup$
2
  • $\begingroup$ Thanks! That works. Can you please tell me what you've done to select or sample from the large data that you had.. the [[1;;-1;;10]] command. $\endgroup$
    – Amatya
    Dec 26, 2013 at 20:46
  • 1
    $\begingroup$ @Amatya this means from 1st element (1) to last (-1) taking each 10th element. I did this so that ticks won't overlap and make a mess. Is this what you are asking about? $\endgroup$ Dec 26, 2013 at 20:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.