Skip to content
Discussion options

You must be logged in to vote

My take on this (uses a fragile hack to overlay the two facets by adding padding: -65 to the specification of fx).

Plot.plot({
  marginBottom: 104,
  fx: { axis: null, padding: -65 },
  y: { grid: true, percent: true },
  color: { legend: true },
  marks: [
    Plot.axisX({ facetAnchor: "left", tickRotate: 90, tickSize: 6 }),
    Plot.barY(
      olympians,
      Plot.groupX(
        { y: "proportion-facet" },
        {
          x: "sport",
          fill: "sex",
          fx: "sex",
          sort: { x: "-y" },
          insetRight: 11,
          dx: 0.5
        }
      )
    ),
    Plot.ruleY([0])
  ]
})

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@gvanhorne
Comment options

@mbostock
Comment options

@Fil
Comment options

Fil Sep 5, 2025
Collaborator

Answer selected by gvanhorne
@gvanhorne
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants