Plot: BarX is leaking on to ticks

The bar in the my plot is overlapping on some of the ticks and also it’s plotting some beyond right most of the ticks. How to fix this to only plot inside the ticks region?

Here is my plot : Vacation Gantt / hashg / Observable

Thanks in advance

Since v0.4.1 (February 17, 2022), Plot has supported a clip property on marks that says they should be clipped to the plot frame. So I just added clip: true to the barX mark:

https://observablehq.com/compare/9228c1470aabf3a1...c28dc4ac7fe8011c

1 Like

If the y scale is ordinal, you don’t want to use Plot.rectX; a rect assumes that both x and y are continuous (quantitative/numbers or temporal/dates). Instead of

    Plot.rectX(days, {
      x1: (d) => d,
      x2: (d) => d3.utcDay.offset(d, 1),
      fill: "#cccccc",
      inset: 1
    }),

Try

    Plot.barX(days, {
      x: (d) => d,
      interval: d3.utcDay,
      fill: "#cccccc"
    }),

Thanks you @tophtucker the solution works perfectly.