Poets of the 19th century
Use the individual legends as tick labels:
dates = Through[{First, Last}@#] & /@ res
{{1769, 1821}, {1775, 1817}, {1770, 1831}, {1818, 1883}, {1777, 1855}, {1766, 1817}, {1870, 1924}}
names={"Napoleon Bonaparte", "Jane Austen", "Hegel", "Marx", "Gauss", "Madame de Stael", "Lenin"};
llpd = MapIndexed[Thread@{#, First@#2} &, dates];
legends = MapIndexed[SwatchLegend[{ColorData[{"Rainbow", {1, 7}}][## & @@ #2]}, {#},
LegendMarkerSize -> {{10, 10}}] &, names];
ListLinePlot[llpd, Joined -> True, ColorFunction -> "Rainbow",
Frame -> True,
FrameTicks -> {{None,Thread[{Range[7], legends}]}, {Range[1750, 1930,20], Automatic}},
GridLines -> {Range[1750, 1920, 10], None},
AxesOrigin -> {1750, 0}, PlotRange -> {{1750, 1930}, {0, 8}},
PlotStyle -> Thickness[0.05], ImageSize -> 600]
Label the bars with names
:
ListPlot[llpd, Joined -> True, ColorFunction -> "Rainbow",
Frame -> True,
FrameTicks -> {{None, None}, {Range[1750, 1930,20], Automatic}},
GridLines -> {Range[1750, 1920, 10], None},
Epilog -> (Text[#2, Mean@#1] & @@@ Transpose[{llpd, names}]),
AxesOrigin -> {1750, 0}, PlotRange -> {{1750, 1930}, {0, 8}},
PlotStyle -> Thickness[0.05], ImageSize -> 600]
Use the option PlotLabels
In versions 10.4+, we can also use the option PlotLabels
:
ListLinePlot[llpd, Joined -> True,
PlotLabels -> legends,
ColorFunction -> "Rainbow", Frame -> True,
GridLines -> {Range[1750, 1920, 10], None}, AxesOrigin -> {1750, 0},
PlotRange -> {{1750, 1930}, {0, 8}}, PlotStyle -> Thickness[0.05],
ImageSize -> 600]
To remove the callout curves, use
% /. _BSplineCurve -> {}
Borrowing from kguler the legends
legends =
MapIndexed[
SwatchLegend[{ColorData[{"Rainbow", {1, 7}}][## & @@ #2]}, {#},
LegendMarkerSize -> {{10, 10}}] &, names];
p1 =
ListLinePlot[par, ColorFunction -> "Rainbow",
Ticks -> {Range[1750, 1980, 10], Automatic},
PlotRangePadding -> {{5, 50}, {0, 1}},
GridLines -> {Range[1750, 1920, 10], None},
PlotStyle -> Thickness[0.02], ImageSize -> 600];
p2 =
Graphics[Inset[
legends[[#]], {1940 + StringLength[names[[#]]], #}] & /@
Range[7]]; Show[p1, p2]