Message Boards Message Boards

1
|
5559 Views
|
8 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Why are Ticks not working Month by Month

Posted 9 years ago

Hi,

I got a simple question.

The Ticks are default in two steps. Example 'Jan' - 'Mar' - 'May' - etc. but I need in only one step: 'Jan' - 'Feb' - 'Mar' - 'Apr' - etc. Why are these not working in my DateListPlot?

DateListPlot[Tooltip[SelNulTen06], PlotLabel -> Style["Year 2006\n0...10 %", "Title", 12], BaseStyle -> {FontFamily -> "Arial", FontWeight -> "Bold", FontSize -> 11}, FrameLabel -> {"Months [n]", "Test [%]"},

Ticks -> {{{1, "Jan"}, {2, "Feb"}, {3, "Mar"}, {4, "Apr"}, {5, "May"}, {6, "Jun"}, {7, "Jul"}, {8, "Aug"}, {9, "Sep"}, {10, "Okt"}, {11, "Nov"}, {12, "Dec"}}, Automatic},

PlotRange -> {Automatic, {-0.1, 10}}, GridLines -> Automatic, GridLinesStyle -> Directive[Black, Dotted], PlotStyle -> Directive[PointSize[Medium], Red], Joined -> False, Filling -> Axis ]

Please can you help ? For details, see file attached.

Thanks...... Jos

Attachments:
POSTED BY: Jos Klaps
8 Replies

Hi,

Thanks to I. van Veen and Michael Mc Cain for your help. This is where looking for. It looks simple but in the description there is no or little information about it.

Thanks again and your support is highly appreciated !

Jos

POSTED BY: Jos Klaps

I think the frame is causing that behavior. You may be able to keep the frame and use some frameticks... but this method here should work just as well. It doesn't include January (the first value) by default just as it doesn't include the 0 tick mark on simple plots. Not sure how to change that off hand... but this should get you started. Hope this helps...

DateListPlot[Tooltip[SelNulTen06],

 Frame -> False,

 Ticks -> {{{2006, 1, 1}, {2006, 2, 1}, {2006, 3, 1}, {2006, 4, 
     1}, {2006, 5, 1}, {2006, 6, 1}, {2006, 7, 1}, {2006, 8, 
     1}, {2006, 9, 1}, {2006, 10, 1}, {2006, 11, 1}, {2006, 12, 1}}, 
   Automatic}

 ]
POSTED BY: Michael McCain

Hi Jos, The label specification is not correct as Michael pointed out. My appologies that I missed out your original question...

For a start I changed your plot:

DateListPlot[Tooltip[SelNulTen06],
 PlotLabel -> Style["Year 2006\n0...10 %", "Title", 12],
 BaseStyle -> {FontFamily -> "Arial", FontWeight -> "Bold", 
   FontSize -> 11},
 Axes -> True,
 FrameLabel -> {"Months [n]", "Test [%]"},

 FrameTicks -> {{Automatic, 
    Automatic}, {{{{2006, 1, 1}, "Jan"}, {{2006, 2, 1}, 
      "Feb"}, {{2006, 3, 1}, "Mar"}, {{2006, 4, 1}, 
      "Apr"}, {{2006, 5, 1}, "May"}, {{2006, 6, 1}, 
      "Jun"}, {{2006, 7, 1}, "Jul"}, {{2006, 8, 1}, 
      "Aug"}, {{2006, 9, 1}, "Sep"}, {{2006, 10, 1}, 
      "Okt"}, {{2006, 11, 1}, "Nov"}, {{2006, 12, 1}, "Dec"}}, 
    Automatic}},

 PlotRange -> {{{2005, 12, 10}, {2006, 12, 31}}, {-0.1, 10}},
 GridLines -> Automatic,
 GridLinesStyle -> Directive[Black, Dotted],
 PlotStyle -> Directive[PointSize[Medium], Red],
 Joined -> False,
 Filling -> Axis
 ]

This produces:

enter image description here

So:

  1. Pay attention to the ticks format (1 is not a dateformat)
  2. When you use a frame and want's ticks specified use FrameTicks
  3. When you use plotrange use some extra range to show the first label.
Attachments:
POSTED BY: l van Veen

Thank you for the detailed explanation. And thank you for the tips... much appreciated!

POSTED BY: Michael McCain

Hi Michael, Thx. I noticed while typing that you basically had the same answer :) I've been fighting with DateListPlot myself and again I find that the documentation is not very precise. Dependencies should be pointed out more and it seems that the examples are carefully crafted not to break anything or are so common for those who document that they forget to mention it.

POSTED BY: l van Veen

Hi,

Thanks for your help en typos (I. van Veen).

My basic question is why the x-ticks 'Month by Month' are not working? The plot shows ticks in steps of two Months: 'Jan', 'Mar', 'May'.'Jul', 'Sep' and 'Nov'. Can someone help me to find out why the ticks are not working 'Month by Month'? ('Jan', 'Feb', 'Mar', 'Apr', etc.). See code above or in a/m attached file 'ticks revised.nb'.

Thanks,.......Jos

POSTED BY: Jos Klaps

Hi all,

Here the right code layout !

DateListPlot[Tooltip[SelNulTen06],
 PlotLabel -> Style["Year 2006\n0...10 %", "Title", 12],
 BaseStyle -> {FontFamily -> "Arial", FontWeight -> "Bold", 
   FontSize -> 11},
 FrameLabel -> {"Months [n]", "Test [%]"},

 Ticks -> {{{1, "Jan"}, {2, "Feb"}, {3, "Mar"}, {4, "Apr"}, {5, 
     "May"}, {6, "Jun"}, {7, "Jul"}, {8, "Aug"}, {9, "Sep"}, {10, 
     "Okt"}, {11, "Nov"}, {12, "Dec"}}, Automatic},

 PlotRange -> {Automatic, {-0.1, 10}},
 GridLines -> Automatic,
 GridLinesStyle -> Directive[Black, Dotted],
 PlotStyle -> Directive[PointSize[Medium], Red],
 Joined -> False,
 Filling -> Axis
 ]
POSTED BY: Jos Klaps

Beste Jos, There are some typos in your notebook. I believe you possibly meant as attached?

Image of plot

Attachments:
POSTED BY: l van Veen
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract