plot = {
let FG_sortedData = _.sortBy(table_data, 'FG_pval');
let FG_E_sortedData = _.sortBy(table_data, 'FG_pval_E');
let BG_sortedData = _.sortBy(table_data, 'BG_pval');
let BG_E_sortedData = _.sortBy(table_data, 'BG_pval_E');
let DF_sortedData = _.sortBy(table_data, 'DF_pval');
let DF_E_sortedData = _.sortBy(table_data, 'DF_pval_E');
let cumulativeData = _.flatMap(FG_sortedData, (d, i) => [
{ facet: "FG", x: d.FG_pval, xE: FG_E_sortedData[i].FG_pval_E, cumsum: i + 1 },
{ facet: "BG", x: BG_sortedData[i].BG_pval, xE: BG_E_sortedData[i].BG_pval_E, cumsum: i + 1 },
{ facet: "DF", x: DF_sortedData[i].DF_pval, xE: DF_E_sortedData[i].DF_pval_E, cumsum: i + 1 }
]);
return Plot.plot({
y: { grid: true, domain: [0, 100] },
facet: {
data: cumulativeData,
x: "facet",
scale: { sort: ["FG", "BG", "DF"] }
},
marks: [
Plot.ruleY([0]),
Plot.lineY(cumulativeData, {x: "x", y: "cumsum", facet: "include", stroke: "steelblue"}),
Plot.areaY(cumulativeData, {x: "x", y: "cumsum", fillOpacity: 0.1, facet: "include"}),
Plot.lineY(cumulativeData, {x: "xE", y: "cumsum", facet: "include", stroke: "red"}),
Plot.areaY(cumulativeData, {x: "xE", y: "cumsum", fillOpacity: 0.3, facet: "include"})
]
});
}