plot4 = Plot.plot({
y: { grid: false, reverse: true, grid: false},
x: {tickFormat: Math.abs, axis: null, grid: false},
marginLeft: 50,
marginRight: 50,
marginTop: 60,
marginBottom: mBottom,
width,
height: height2,
label: null,
marks: [
Plot.axisX({ticks: [ -100000, -200000, -300000, -400000, -500000],
tickFormat: d => Math.abs(d)/1000, fill: "transparent", dx:-dX, dy:0}),
Plot.axisX({ ticks: [ 100000, 200000, 300000, 400000, 500000],
tickFormat: d => Math.abs(d)/1000, fill: "transparent", dx: dX, dy:0}),
Plot.axisY({
frameAnchor: "middle",
dx: 32,
tickSize: 30,
ticks: [0,10,20,30,40,50,60,70,80,90,100],
label: null,
stroke: "white",
textStroke: "white",
textStrokeWidth: 0,
fontSize: 14,
textAnchor: "middle"
}),
Plot.text(["↑ Ages"], { frameAnchor: "top", dy: -20, dx: -4, fontSize:labSize }),
Plot.barX(df, { x: (d) => -d.hommes, y: "age", dx: -27,
channels: {Age: {value: 'age', label: 'Age:'},
anneeLab: {value: "anneeLab", label: 'Année de naissance:'},
Hommes: {value: 'hommes', label: "Nombre d'hommes:"}, },
fill: color[0], fillOpacity: 1,
stroke: color[0], strokeWidth: 2 ,
rx:.5, inset:0,
tip: {format: {x: false, y: false, Hommes: (d) => `${d.toLocaleString("fr-FR")}`},anchor: "top", stroke: "black", fontSize:12}}),
Plot.barX(df, { x: (d) => d.femmes , y: "age", dx: 27,
channels: {Age: {value: 'age', label: 'Age:'},
anneeLab: {value: "anneeLab", label: 'Année de naissance:'},
Femmes: {value: 'femmes', label: 'Nombre de femmes:'}},
fill: color[0], fillOpacity: 1,
stroke: color[0], strokeWidth: 2 ,
rx:.5, inset:0,
tip: {format: {x: false, y: false, Femmes: (d) => `${d.toLocaleString("fr-FR")}`}, anchor: "bottom", stroke: "black"} }),
Plot.image(df,{ x: "xc", y: "yc" , src: question,
channels: {xc: {value: 'xx', label: ''},
yc: {value: 'xy', label: ''},
comment: {value: 'comment', label: "" }}
, dx:+20, r: radius,
tip: {format: {x: false, y: false, comment: true}, lineWidth: 20, dx: +15},
anchor: "top", title: (d) => [d.comment].join("\n\n")}),
Plot.text(['Femmes →'], {x: d=> 200000, y: d=>100, dy: -20.5, textAnchor: "start", fontWeight:600, fontSize: labSize}),
Plot.text(['← Hommes'], {x: d=> -200000, y: d=>100, dy: -20.5, textAnchor: "end", fontWeight: 600, fontSize: labSize}),
Plot.text(["Effectifs (en milliers)"], { frameAnchor: "bottom", dy:50, fontSize: labSize }),
Plot.text(["500"], {x: d => -500000, y:d => 0, dy:24, dx: -dX, fontSize: popSize}),
Plot.text(["400"], {x: d => -400000, y:d => 0, dy:tick, dx: -dX, fontSize: popSize}),
Plot.text(["300"], {x: d => -300000, y:d => 0, dy:24, dx: -dX, fontSize: popSize}),
Plot.text(["200"], {x: d => -200000, y:d => 0, dy:tick, dx: -dX, fontSize: popSize}),
Plot.text(["100"], {x: d => -100000, y:d => 0, dy:24, dx: -dX, fontSize: popSize}),
Plot.text(["500"], {x: d => 500000, y:d => 0, dy:24, dx: dX, fontSize: popSize}),
Plot.text(["400"], {x: d => 400000, y:d => 0, dy:tick, dx: dX, fontSize: popSize}),
Plot.text(["300"], {x: d => 300000, y:d => 0, dy:24, dx: dX, fontSize: popSize}),
Plot.text(["200"], {x: d => 200000, y:d => 0, dy:tick, dx: dX, fontSize: popSize}),
Plot.text(["100"], {x: d => 100000, y:d => 0, dy:24, dx: dX, fontSize: popSize}),
]
})