Barx-Timeline
For a richer example, we'll use some sample data from ancient civilizations.
Below: a barX mark specifies x1 and x2 channels to show civilization timespans, with a text mark providing labels that align with the bars. Both marks use the civilization name for the y channel. Color is used to indicate the continent, and a legend is provided.
(
Plot.barX(
civilizations,
{
"x1": "start",
"x2": "end",
"y": "name",
"fill": "continent",
"sort": {"y": "x1"},
},
)
+ Plot.text(
civilizations,
{"text": "name", "x": "start", "y": "name", "textAnchor": "end", "dx": -3},
)
+ {"axis": None, "marginLeft": 100}
+ Plot.colorLegend()
)