plot
plot copied to clipboard
monotone X for lineY?
We could have an option to sort the scaled X channel of a lineY—currently the sort option sorts the unscaled channel, which makes it difficult to sort x if it is ordinal with an arbitrary domain. It's also difficult to sort a line connecting groups. For an example see https://observablehq.com/d/50d4e8b7d32bf564#cell-102
Plot.plot({
marginLeft: 70,
x: {
line: true,
domain: ["Oceania", "Africa", "Americas", "Asia", "Europe"] // setting the order manually by specifying the array
},
y: {
line: true
},
marks: [
Plot.barY(
countries,
Plot.groupX({ y: "max" }, { y: "fert_rate", x: "region", fillOpacity: 0.5 })
),
Plot.lineY(
countries,
Plot.groupX({ y: "max", sort: ([{ region }]) => ["Oceania", "Africa", "Americas", "Asia", "Europe"].indexOf(region) }, { y: "fert_rate", x: "region", strokeWidth: 10, strokeDasharray: "1", strokeLinecap: "butt" })
)
]
})