Facet Label Overlap

Is there anyway to offset the facet labels from the axis labels? I have a plot that is fairly tall and needed to label both.

Ex:

Sample code:

Plot.plot({
  grid: true,
  marginRight: 60,
  facet: {label: null},
  x: { axis: 'both'},
  marks: [
    Plot.frame(),
    Plot.dot(penguins.filter(d=>d.species==='Adelie'), {
      x: "culmen_length_mm",
      y: "culmen_depth_mm",
      fx: "sex",
      fy: "species"
    })
  ]
})

Thanks!
Steve

You can declare an explicit fx axis mark and then use the dy option to shift the axis vertically.

Plot.plot({
  grid: true,
  marginTop: 42,
  x: { axis: "both" },
  marks: [
    Plot.axisFx({ dy: -12 }),
    Plot.frame(),
    Plot.dot(penguins, {
      x: "culmen_length_mm",
      y: "culmen_depth_mm",
      fx: "sex"
    })
  ]
})

https://observablehq.com/@observablehq/plot-facet-margin-example

Perfect, thanks!

Steve

1 Like