6
$\begingroup$

unfortunately, I have a simple problem with my DateListPlot which I cannot solve on my own (with the guidance online).

The code looks as follows:

DateListPlot[{{100, 106, 104, 106, 112, 112, 112, 119, 124, 109, 115,124, 123, 125, 122}, {100, 100, 101, 105, 105, 109, 107, 114, 115,101, 111, 115, 118, 121, 120}, {100, 96, 91, 101, 113, 115, 115,120, 121, 112, 114, 112, 114, 105, 111}, {100, 94, 93, 90, 84, 78,78, 79, 83, 90, 95, 96, 103, 104, 102}, {100, 108, 115, 107, 104,105, 105, 101, 98, 100, 107, 102, 96, 101, 96}, {100, 96, 88, 91,92, 89, 90, 92, 88, 83, 86, 93, 88, 95, 96}, {100, 101, 96, 96, 94,93, 95, 90, 91, 85, 85, 86, 84, 88, 91}, {100, 93, 89, 86, 93, 92,84, 71, 65, 60, 64, 66, 68, 70, 74}, {100, 107, 101, 103, 109,110, 94, 97, 89, 77, 75, 78, 70, 71, 72}, {100, 97, 92, 91, 97, 98, 95, 78, 73, 73, 62, 55, 60, 61, 61}}, {"2000", "2014"}, PlotLegends -> {"DEU:C28", "DEU:C29", "FRA:F", "DEU:F", "USA:O84","DEU:C20", "JPN:F", "USA:C29", "FRA:C29", "USA:F"}, 
 PlotRange -> {40, 140},PlotStyle -> {{None}, {None}, {Dashed}, {Dashed}, {Dashed},{Dashed}, {Dashed}, {None}, {None}, {None}}, PlotLabel -> 
  Style["Development of Top 10 Sectors with Highest Degree in 2000", FontSize -> 12], Frame -> True, FrameLabel -> {None, "Index"}, ImageSize -> 400]

When I plot the line chart, however, just the years 2000, 2005 and 2010 are displayed. This is somehow inconvenient, and I would like to change the scale of the x-axis to a yearly or two-year basis. This means I would like to display every year on the x-axis or every second.

Can someone please help me and tell me, how to change the x-axis labelling accordingly?

Thank you in advance!

Best regards Alex

$\endgroup$

1 Answer 1

6
$\begingroup$

You can use FrameTicks to specify which ticks and how you want to display (see the docs of DateListPlot->Options->FrameTicks). I offer here also a rotation of the ticks by 45 degrees so that they are readable when so dense:

ticks = Range[2000, 2014];
center = Row[{#, Invisible[#]}, "\[NegativeThickSpace]"] &;
xticks = Transpose@{Partition[ticks, 1],
     (center@Rotate[#, 45 Degree] &) /@ ticks};

Your DateListPlot with added FrameTicks -> {{Automatic, Automatic}, {xticks, Automatic}}:

enter image description here

$\endgroup$
1
  • $\begingroup$ Wow, thank you very much @corey979 for your immediate reply! Great! $\endgroup$ Sep 6, 2017 at 10:26

Your Answer

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

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