Facet label placement

Is there a place to specify the facet label placement? I have some Plot code like this (notebook here):

Plot.plot({
  facet: {
    data: weather,
    y: "weather"   
    },
  marks: [
    Plot.dot(weather, {
        x: "date", 
        y: "precipitation", 
        fy: "weather",
        stroke: "weather"
      })
  ]
})

From that I’d like to be able to place the label (currently on the right side of the plot) to the top of each facet but maintain the ncol = 1 facet organization. I’ve tried playing around with facetAnchor and labelAnchor but I don’t see quite how I might do this.

Suggestion:

Plot.plot({
  fy: { axis: null },
  marks: [
    Plot.dot(weather, {
      x: "date",
      y: "precipitation",
      fy: "weather",
      stroke: "weather"
    }),
    Plot.text(
      weather,
      Plot.selectFirst({
        fy: "weather",
        text: "weather",
        frameAnchor: "top-right"
      })
    )
  ]
})

then use dx and dy to give more breathing room

1 Like