7
$\begingroup$

Bug introduced in 10.1 and fixed in 10.3
TimeLinePlot was introduced in 10.1


I have some data from wikipedia.

str = URLFetch["http://en.wikipedia.org/wiki/Mathematica"];
AllDate = StringCases[str, DatePattern[{"MonthName", " ", "Day", ", ","Year"}]][[;; 26]];
AllVersion = StringCases[str, "<li>Mathematica " ~~ Shortest[v__] ~~ "(" :> v][[-26 ;;]];

Now I can show some interesting,like this:

ShowDifferenceDate[version_, 
   date_] := {Rule @@@ Partition[version, 2, 1], 
      DateDifference[##, {"Year"}] & @@@ Partition[date, 2, 1]} // 
      Transpose // Flatten // Partition[#, 4, 4, 1, " "] & // TableForm;
{someVersion, someDate} = Transpose[GatherBy[Transpose[{AllVersion, AllDate}], 
      StringTake[First@#, 1 ;; 2] &][[All, 1]]];
ShowDifferenceDate[AllVersion, AllDate]
ShowDifferenceDate[someVersion, someDate]

picture 1 enter image description here

picture 2 enter image description here

Now I want to use TimelinePlot.It is Ok like this:

TimelinePlot[Association[Rule @@@ Transpose@{AllVersion, DateList /@ AllDate}]]

picture 3 enter image description here

It is ugly.So I want to make it beautiful.For example,different colors for different Big Version(1.0,1.1,1.2 are the same color, but 1.0,2.0 are different color).So I try to do this:

TimelinePlot[Association /@ 
  GatherBy[Rule@@@Transpose@{AllVersion,DateList/@AllDate}, StringTake[First@#, 1 ;; 2] &]]

But it Failed.

Part::partw : Part2 of {{Directive[AbsolutePointSize[5], RGBColor[0.368, 0.507, 0.710],AbsoluteThickness[1.6`], Opacity1]}} does not exist.

Why it Failed? Is it bug about TimelinePlot?

How to make this picture(TimelinePlot) beautiful?

Thanks!

$\endgroup$
6
  • $\begingroup$ @Mahdi Thanks for pointing out my mistake! $\endgroup$
    – Apple
    May 29, 2015 at 8:17
  • $\begingroup$ You're welcome. I had a typo in my own comment, so funny! :D $\endgroup$
    – Mahdi
    May 29, 2015 at 8:32
  • $\begingroup$ @Mahdi Did you post the answer as a comment and then delete it? I'm trying to figure out whether this question can be closed or not, and it's complicated if I don't know for sure that it's been answered or whether the mistake was "simple" (requirement for closing the question.) $\endgroup$
    – C. E.
    May 29, 2015 at 12:08
  • 2
    $\begingroup$ @Pickett Sorry.My code is missing a comma at the beginning due to my carelessness,so Mahdi told me this mistake,and then I add one comma in my code.But my problem is not settled. $\endgroup$
    – Apple
    May 29, 2015 at 12:28
  • $\begingroup$ It appears that TimeLinePlot doesn't work correctly with lists of associations. $\endgroup$ May 30, 2015 at 0:38

3 Answers 3

5
$\begingroup$

This bug appears to be fixed in MMA 10.3:

enter image description here

$\endgroup$
5
$\begingroup$

One can workaround this issue by using nested lists instead of associations.

TimelinePlot[GatherBy[
  Rule @@@ Transpose@{DateList /@ AllDate, AllVersion}, 
  StringTake[Last@#, 1 ;; 2] &
]]

enter image description here

$\endgroup$
3
$\begingroup$

It appears that TimelinePlot doesn't handle multiple Associations very gracefully. One imperfect workaround is to use Show

tlp1 = TimelinePlot[{Entity["HistoricalEvent", "WorldWar2"], 
Entity["HistoricalEvent", "VietnamWar"]}];

tlp2 = TimelinePlot[{Style[{Entity["HistoricalEvent", "WorldWar1"], 
  Entity["HistoricalEvent", "KoreanWarBegins"]}, Red]}];

Show[tlp1, tlp2]

Gives :

enter image description here

You can probably tweak it but you get the gist.

$\endgroup$
2
  • $\begingroup$ Multiple associations should work however, right? So I think this is a bug; do you? $\endgroup$
    – Mr.Wizard
    May 30, 2015 at 1:30
  • $\begingroup$ @mr.wizard. I agree. Tried it with Datasets too with similar errors. $\endgroup$ May 30, 2015 at 8:24

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.