Message Boards Message Boards

0
|
2687 Views
|
4 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Formatting Ticks on TimeLinePlot

Posted 1 year ago

Hi everyone,

Is there a way to force TimeLinePlot to display ticks and tick labels only for the dates of the events themselves? Here's an example containing an interval, Feb 1973 through May 2013, and an event occurring on a specific date, Feb 7, 2011.

data = {
   {
    Labeled[DateInterval[{{1973, 09, 01}, {2013, 05, 31}}], 
     "Events spans an interval"],
    Labeled[{2011, 02, 07}, "Event on a specific date"]}
   };

TimelinePlot[data, PlotLayout -> "Horizontal",
 DateTicksFormat -> {"MonthNameShort", " ", "Year"},
 PlotRange -> {{1970, 01, 01}, {2022, 11, 01}},
 ImageSize -> {Automatic, 300}]

When I run this, I get a timeline whose ticks marks are spaced two years apart (see attached file) and labelled as such, but what I want to show is a tick mark and label only for the three dates in my data. Is there a way to do that using the Ticks option?

Greg

Attachments:
POSTED BY: Gregory Lypny
4 Replies

Hi Gregory,

Thanks for sharing your solution. It works perfectly!

Best Regards,...Jos

POSTED BY: Jos Klaps
Posted 1 year ago

Hi Jos,

Sorry for late reply. Have a look at this.

timelineData = <|
   "Rock Around the Clock" -> "1954-05-20",
   "All Along the Watchtower" -> "1967-12-07",
   "Sultans of Swing" -> "1978-05-19"
   |>;

TimelinePlot[timelineData,
 AspectRatio -> 1/8,
 Ticks -> {Values[timelineData], 
   Automatic},(*restrict the ticks to just the dates*)

 DateTicksFormat -> {"DayShort", " ", "MonthNameShort", " ", 
   "Year"},(*format the dates*)
 Spacings -> {1, 52, 34},
 BaseStyle -> {FontFamily -> "Futura", FontColor -> Black, 
   FontSize -> 11}, 
 LabelStyle -> {FontFamily -> "Futura", FontColor -> Black, 
   FontSize -> 11}, 
 PlotLabel -> 
  Style["RECORD RELEASE", FontFamily -> "Futura", FontSize -> 14, 
   FontColor -> Black], ImageSize -> 860]
POSTED BY: Gregory Lypny

Hi Greg,

I'm interested. can you let me know how you solved it?

Thanks in advance! ...... Jos

POSTED BY: Jos Klaps
Posted 1 year ago

Just figured it out.

POSTED BY: Gregory Lypny
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